summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-04-24 15:10:34 +0000
committerDries Buytaert <dries@buytaert.net>2010-04-24 15:10:34 +0000
commitf95577fe6cee4438159df47c40d179c9bba4dae9 (patch)
tree2461ec33d43fa9267b42b940b8116f55da899e76
parentdf52ebb726d80df59255667ce807d8aa3463be28 (diff)
downloadbrdo-f95577fe6cee4438159df47c40d179c9bba4dae9.tar.gz
brdo-f95577fe6cee4438159df47c40d179c9bba4dae9.tar.bz2
- Patch #779362 by ksenzee, dereine: drupal_match_path() is unreadable.
-rw-r--r--includes/path.inc15
1 files changed, 14 insertions, 1 deletions
diff --git a/includes/path.inc b/includes/path.inc
index 9e38d1171..ee6286266 100644
--- a/includes/path.inc
+++ b/includes/path.inc
@@ -362,7 +362,20 @@ function drupal_match_path($path, $patterns) {
$regexps = &drupal_static(__FUNCTION__);
if (!isset($regexps[$patterns])) {
- $regexps[$patterns] = '/^(' . preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'), preg_quote($patterns, '/')) . ')$/';
+ // Convert path settings to a regular expression.
+ // Therefore replace newlines with a logical or, /* with asterisks and the <front> with the frontpage.
+ $to_replace = array(
+ '/(\r\n?|\n)/', // newlines
+ '/\\\\\*/', // asterisks
+ '/(^|\|)\\\\<front\\\\>($|\|)/' // <front>
+ );
+ $replacements = array(
+ '|',
+ '.*',
+ '\1' . preg_quote(variable_get('site_frontpage', 'node'), '/') . '\2'
+ );
+ $patterns_quoted = preg_quote($patterns, '/');
+ $regexps[$patterns] = '/^(' . preg_replace($to_replace, $replacements, $patterns_quoted) . ')$/';
}
return (bool)preg_match($regexps[$patterns], $path);
}