summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-07 07:45:03 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-01-07 07:45:03 +0000
commit436ddca9fbf0eb955a06b5262e8f2ba1e9d25afd (patch)
treee581a6713185f02be31cb7109769d6c7f84f13b2
parent1407c81632b6279c550a07f8f1b08120f19f344d (diff)
downloadbrdo-436ddca9fbf0eb955a06b5262e8f2ba1e9d25afd.tar.gz
brdo-436ddca9fbf0eb955a06b5262e8f2ba1e9d25afd.tar.bz2
#265719 by kkaefer, JacobSingh, ksenzee, and rfay: Fixed CSS aggregator produces invalid code and directory names for @import files which breaks IE (with tests).
-rw-r--r--includes/common.inc13
-rw-r--r--modules/simpletest/files/css_test_files/css_input_with_import.css30
-rw-r--r--modules/simpletest/files/css_test_files/css_input_with_import.css.optimized.css6
-rw-r--r--modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized.css30
-rw-r--r--modules/simpletest/files/css_test_files/import1.css6
-rw-r--r--modules/simpletest/files/css_test_files/import2.css5
-rw-r--r--modules/simpletest/tests/common.test5
7 files changed, 92 insertions, 3 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 6d69a18dd..4abd62b1b 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3497,8 +3497,17 @@ function _drupal_load_stylesheet($matches) {
$filename = $matches[1];
// Load the imported stylesheet and replace @import commands in there as well.
$file = drupal_load_stylesheet($filename);
- // Alter all url() paths, but not external.
- return preg_replace('/url\(([\'"]?)(?![a-z]+:)([^\'")]+)[\'"]?\)?;/i', 'url(\1' . dirname($filename) . '/', $file);
+
+ // Determine the file's directory.
+ $directory = dirname($filename);
+ // If the file is in the current directory, make sure '.' doesn't appear in
+ // the url() path.
+ $directory = $directory == '.' ? '' : $directory .'/';
+
+ // Alter all internal url() paths. Leave external paths alone. We don't need
+ // to normalize absolute paths here (i.e. remove folder/... segments) because
+ // that will be done later.
+ return preg_replace('/url\s*\(([\'"]?)(?![a-z]+:|\/+)/i', 'url(\1'. $directory, $file);
}
/**
diff --git a/modules/simpletest/files/css_test_files/css_input_with_import.css b/modules/simpletest/files/css_test_files/css_input_with_import.css
new file mode 100644
index 000000000..87afcb35f
--- /dev/null
+++ b/modules/simpletest/files/css_test_files/css_input_with_import.css
@@ -0,0 +1,30 @@
+
+
+@import "import1.css";
+@import "import2.css";
+
+body {
+ margin: 0;
+ padding: 0;
+ background: #edf5fa;
+ font: 76%/170% Verdana, sans-serif;
+ color: #494949;
+}
+
+.this .is .a .test {
+ font: 1em/100% Verdana, sans-serif;
+ color: #494949;
+}
+.this
+.is
+.a
+.test {
+font: 1em/100% Verdana, sans-serif;
+color: #494949;
+}
+
+textarea, select {
+ font: 1em/160% Verdana, sans-serif;
+ color: #494949;
+}
+
diff --git a/modules/simpletest/files/css_test_files/css_input_with_import.css.optimized.css b/modules/simpletest/files/css_test_files/css_input_with_import.css.optimized.css
new file mode 100644
index 000000000..60006c583
--- /dev/null
+++ b/modules/simpletest/files/css_test_files/css_input_with_import.css.optimized.css
@@ -0,0 +1,6 @@
+
+ul,select{font:1em/160% Verdana,sans-serif;color:#494949;}.ui-icon{background-image:url(images/icon.png);}
+p,select{font:1em/160% Verdana,sans-serif;color:#494949;}body{margin:0;padding:0;background:#edf5fa;font:76%/170% Verdana,sans-serif;color:#494949;}.this .is .a .test{font:1em/100% Verdana,sans-serif;color:#494949;}.this
+.is
+.a
+.test{font:1em/100% Verdana,sans-serif;color:#494949;}textarea,select{font:1em/160% Verdana,sans-serif;color:#494949;} \ No newline at end of file
diff --git a/modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized.css b/modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized.css
new file mode 100644
index 000000000..4c905f562
--- /dev/null
+++ b/modules/simpletest/files/css_test_files/css_input_with_import.css.unoptimized.css
@@ -0,0 +1,30 @@
+
+
+
+
+
+body {
+ margin: 0;
+ padding: 0;
+ background: #edf5fa;
+ font: 76%/170% Verdana, sans-serif;
+ color: #494949;
+}
+
+.this .is .a .test {
+ font: 1em/100% Verdana, sans-serif;
+ color: #494949;
+}
+.this
+.is
+.a
+.test {
+font: 1em/100% Verdana, sans-serif;
+color: #494949;
+}
+
+textarea, select {
+ font: 1em/160% Verdana, sans-serif;
+ color: #494949;
+}
+
diff --git a/modules/simpletest/files/css_test_files/import1.css b/modules/simpletest/files/css_test_files/import1.css
new file mode 100644
index 000000000..3d5842ece
--- /dev/null
+++ b/modules/simpletest/files/css_test_files/import1.css
@@ -0,0 +1,6 @@
+
+ul, select {
+ font: 1em/160% Verdana, sans-serif;
+ color: #494949;
+}
+.ui-icon{background-image: url(images/icon.png);} \ No newline at end of file
diff --git a/modules/simpletest/files/css_test_files/import2.css b/modules/simpletest/files/css_test_files/import2.css
new file mode 100644
index 000000000..367eb5711
--- /dev/null
+++ b/modules/simpletest/files/css_test_files/import2.css
@@ -0,0 +1,5 @@
+
+p, select {
+ font: 1em/160% Verdana, sans-serif;
+ color: #494949;
+}
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index c44d2947e..e1a45dad2 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -757,7 +757,9 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
*
* This can be enhanced by adding additional CSS files with variant test cases.
* Currently, this is specifically testing to make sure that whitespace
- * is treated with adequate respect (not arbitrarily removing linefeeds).
+ * is treated with adequate respect (see http://drupal.org/node/472820) and
+ * that image paths in imported files are preserved (see
+ * http://drupal.org/node/265719).
*/
function testLoadCssBasic() {
// Array of files to test living in 'simpletest/files/css_test_files/'.
@@ -766,6 +768,7 @@ class CascadingStylesheetsUnitTest extends DrupalUnitTestCase {
// - Optimized expected content: name.css.optimized.css
$testfiles = array(
'css_input_without_import.css',
+ 'css_input_with_import.css'
);
$path = drupal_get_path('module', 'simpletest') . '/files/css_test_files';
foreach ($testfiles as $file) {