diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc index d8661100c..c264147e9 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -486,7 +486,11 @@ function drupal_get_destination() { } /** - * Wrapper around parse_url() to parse a given URL into an associative array, suitable for url(). + * Wrapper around parse_url() to parse a system URL string into an associative array, suitable for url(). + * + * This function should only be used for URLs that have been generated by the + * system, resp. url(). It should not be used for URLs that come from external + * sources, or URLs that link to external resources. * * The returned array contains a 'path' that may be passed separately to url(). * For example: @@ -552,6 +556,13 @@ function drupal_parse_url($url) { $options['fragment'] = $parts['fragment']; } } + // The 'q' parameter contains the path of the current page if clean URLs are + // disabled. It overrides the 'path' of the URL when present, even if clean + // URLs are enabled, due to how Apache rewriting rules work. + if (isset($options['query']['q'])) { + $options['path'] = $options['query']['q']; + unset($options['query']['q']); + } return $options; } |