diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 13 |
1 files changed, 11 insertions, 2 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); } /** |