Commit 6cacff4b authored by webchick's avatar webchick
Browse files

#298561 by Steven, chx, mcarbone, pwolanin: Fixed slashes don't work in search

parent e19a50d2
......@@ -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
......
......@@ -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',
......
......@@ -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.');
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment