summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-20 08:27:52 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-20 08:27:52 +0000
commit7ec15ec28532df021266befde408cf8df47b7dda (patch)
tree96078aac50af0d4c6cfa981f32aac2d01d6d97ca
parent1cf5ba30ddc9fd3a605d199826ac3f5818fcce8a (diff)
downloadbrdo-7ec15ec28532df021266befde408cf8df47b7dda.tar.gz
brdo-7ec15ec28532df021266befde408cf8df47b7dda.tar.bz2
#460448 follow-up by chx: Replace advanced regex incompatible with PCRE < 7.2 with function-based approach.
-rw-r--r--includes/common.inc22
1 files changed, 14 insertions, 8 deletions
diff --git a/includes/common.inc b/includes/common.inc
index c8848f5cd..861bdf938 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -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.
@@ -3514,6 +3510,16 @@ function drupal_load_stylesheet_content($contents, $optimize = FALSE) {
}
/**
+ * 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.
*
* This function is used for recursive loading of stylesheets and