From 632ae14d9cd4ed60c6fe365ca15f1d3904bc165b Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Wed, 10 Mar 2010 19:36:14 +0000 Subject: #587706 follow-up by plach: trim GET['q'] centrally in request_path() so subsequent places don't have to do it. --- includes/bootstrap.inc | 5 +++++ includes/language.inc | 2 +- includes/path.inc | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 5dd22249d..a5b2d1afd 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -2188,6 +2188,11 @@ function request_path() { $path = ''; } + // Under certain conditions Apache's RewriteRule directive prepends the value + // assigned to $_GET['q'] with a slash. Moreover we can always have a trailing + // slash in place, hence we need to normalize $_GET['q']. + $path = trim($path, '/'); + return $path; } diff --git a/includes/language.inc b/includes/language.inc index 608ed112e..43a4961a0 100644 --- a/includes/language.inc +++ b/includes/language.inc @@ -359,7 +359,7 @@ function language_from_default() { * - The path without the prefix on success, the given path otherwise. */ function language_url_split_prefix($path, $languages) { - $args = empty($path) ? array() : explode('/', trim($path, '/')); + $args = empty($path) ? array() : explode('/', $path); $prefix = array_shift($args); // Search prefix within enabled languages. diff --git a/includes/path.inc b/includes/path.inc index 240f375f0..9e38d1171 100644 --- a/includes/path.inc +++ b/includes/path.inc @@ -15,7 +15,7 @@ */ function drupal_path_initialize() { if (!empty($_GET['q'])) { - $_GET['q'] = drupal_get_normal_path(trim($_GET['q'], '/')); + $_GET['q'] = drupal_get_normal_path($_GET['q']); } else { $_GET['q'] = drupal_get_normal_path(variable_get('site_frontpage', 'node')); -- cgit v1.2.3