From 6cacff4b4e4494c05f90604849dc8803c7506ae0 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 23 Nov 2010 06:00:27 +0000 Subject: #298561 by Steven, chx, mcarbone, pwolanin: Fixed slashes don't work in search --- includes/menu.inc | 20 ++++++++++++++++++++ modules/search/search.module | 1 + modules/search/search.test | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/includes/menu.inc b/includes/menu.inc index e3adaaf3e..b19abdbb4 100644 --- a/includes/menu.inc +++ b/includes/menu.inc @@ -787,10 +787,30 @@ function _menu_link_map_translate(&$map, $to_arg_functions) { } } +/** + * Returns path as one string from the argument we are currently at. + */ function menu_tail_to_arg($arg, $map, $index) { return implode('/', array_slice($map, $index)); } +/** + * Loads path as one string from the argument we are currently at. + * + * To use this load function, you must specify the load arguments + * in the router item as: + * @code + * $item['load arguments'] = array('%map', '%index'); + * @endcode + * + * @see search_menu(). + */ +function menu_tail_load($arg, &$map, $index) { + $arg = implode('/', array_slice($map, $index)); + $map = array_slice($map, 0, $index); + return $arg; +} + /** * This function is similar to _menu_translate() but does link-specific * preparation such as always calling to_arg functions diff --git a/modules/search/search.module b/modules/search/search.module index d6e6350ae..1f4238797 100644 --- a/modules/search/search.module +++ b/modules/search/search.module @@ -210,6 +210,7 @@ function search_menu() { ); $items["$path/%menu_tail"] = array( 'title' => $search_info['title'], + 'load arguments' => array('%map', '%index'), 'page callback' => 'search_view', 'page arguments' => array($module, 2), 'access callback' => '_search_menu_access', diff --git a/modules/search/search.test b/modules/search/search.test index 35f363a67..78c3cfae2 100644 --- a/modules/search/search.test +++ b/modules/search/search.test @@ -279,6 +279,13 @@ class SearchPageText extends DrupalWebTestCase { $this->drupalPost('search/user', $edit, t('Search')); $this->assertText(t('Search')); $this->assertTitle($title, 'Search page title is correct'); + + // Test that search keywords containing slashes are correctly loaded + // from the path and displayed in the search form. + $arg = $this->randomName() . '/' . $this->randomName(); + $this->drupalGet('search/node/' . $arg); + $input = $this->xpath("//input[@id='edit-keys' and @value='{$arg}']"); + $this->assertFalse(empty($input), 'Search keys with a / are correctly set as the default value in the search box.'); } } -- cgit v1.2.3