From f95577fe6cee4438159df47c40d179c9bba4dae9 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 24 Apr 2010 15:10:34 +0000 Subject: - Patch #779362 by ksenzee, dereine: drupal_match_path() is unreadable. --- includes/path.inc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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)/', '/\\\\\*/', '/(^|\|)\\\\($|\|)/'), 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 with the frontpage. + $to_replace = array( + '/(\r\n?|\n)/', // newlines + '/\\\\\*/', // asterisks + '/(^|\|)\\\\($|\|)/' // + ); + $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); } -- cgit v1.2.3