Commit 7ec15ec2 authored by webchick's avatar webchick

#460448 follow-up by chx: Replace advanced regex incompatible with PCRE < 7.2...

#460448 follow-up by chx: Replace advanced regex incompatible with PCRE < 7.2 with function-based approach.
parent 1cf5ba30
......@@ -738,7 +738,7 @@ function drupal_access_denied() {
* call may take. The default is 30 seconds. If a timeout occurs, the error
* code is set to the HTTP_REQUEST_TIMEOUT constant.
* - context: A context resource created with stream_context_create().
*
*
* @return object
* An object that can have one or more of the following components:
* - request: A string containing the request body that was sent.
......@@ -3482,12 +3482,9 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
);
// Remove certain whitespace.
// There are different conditions for removing leading and trailing
// whitespace. To be able to use a single backreference in the replacement
// string, the outer pattern uses the ?| modifier, which makes all contained
// subpatterns appear in \1.
// whitespace.
// @see http://php.net/manual/en/regexp.reference.subpatterns.php
$contents = preg_replace('<
(?|
$contents = preg_replace_callback('<
# Strip leading and trailing whitespace.
\s*([@{};,])\s*
# Strip only leading whitespace from:
......@@ -3497,9 +3494,8 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
# - Opening parenthesis: Retain "@media (bar) and foo".
# - Colon: Retain :pseudo-selectors.
| ([\(:])\s+
)
>xS',
'\1',
'_drupal_load_stylesheet_content',
$contents
);
// End the file with a new line.
......@@ -3513,6 +3509,16 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
return $contents;
}
/**
* Helper for drupal_load_stylesheet_content().
*/
function _drupal_load_stylesheet_content($matches) {
// Discard the full match.
unset($matches[0]);
// Use the non-empty match.
return current(array_filter($matches));
}
/**
* Loads stylesheets recursively and returns contents with corrected paths.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment