Commit f31db8d7 authored by Steven Wittens's avatar Steven Wittens

- #22850: Search query containing / results in 404 on clean URLs.

parent 6777fdb1
......@@ -1295,6 +1295,18 @@ function drupal_implode_autocomplete($array) {
return implode('||', $output);
}
/**
* Wrapper around urlencode() which avoids Apache quirks.
*
* Should be used when placing arbitrary data inside the path of a clean URL.
*
* @param $text
* String to encode
*/
function drupal_urlencode($text) {
return variable_get('clean_url', '0') ? str_replace('%2F', '/', urlencode($text)) : urlencode($text);
}
/**
* Performs one or more XML-RPC request(s).
*
......
......@@ -74,7 +74,7 @@ function theme__locale_admin_manage_screen($form) {
foreach ($form['name'] as $key => $element) {
// Don't take form control structures
if (is_array($element) && element_child($key)) {
$rows[] = array(check_plain($key), form_render($form['name'][$key]), form_render($form['enabled'][$key]), form_render($form['sitedefault'][$key]), ($key != 'en' ? form_render($form['translation'][$key]) : message_na()), ($key != 'en' ? l(t('delete'), 'admin/locale/language/delete/'. urlencode($key)) : ''));
$rows[] = array(check_plain($key), form_render($form['name'][$key]), form_render($form['enabled'][$key]), form_render($form['sitedefault'][$key]), ($key != 'en' ? form_render($form['translation'][$key]) : message_na()), ($key != 'en' ? l(t('delete'), 'admin/locale/language/delete/'. drupal_urlencode($key)) : ''));
}
}
$header = array(array('data' => t('Code')), array('data' => t('English name')), array('data' => t('Enabled')), array('data' => t('Default')), array('data' => t('Translated')), array('data' => t('Operations')));
......
......@@ -252,9 +252,9 @@ function profile_view_field($user, $field) {
case 'textarea':
return check_markup($value);
case 'selection':
return $browse ? l($value, "profile/$field->name/$value") : check_plain($value);
return $browse ? l($value, 'profile/'. drupal_urlencode($field->name) .'/'. drupal_urlencode($value)) : check_plain($value);
case 'checkbox':
return $browse ? l($field->title, "profile/$field->name") : check_plain($field->title);
return $browse ? l($field->title, 'profile/'. drupal_urlencode($field->name)) : check_plain($field->title);
case 'url':
return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
case 'date':
......@@ -273,7 +273,7 @@ function profile_view_field($user, $field) {
$fields = array();
foreach ($values as $value) {
if ($value = trim($value)) {
$fields[] = $browse ? l($value, "profile/". urlencode($field->name) ."/". urlencode($value)) : check_plain($value);
$fields[] = $browse ? l($value, "profile/". drupal_urlencode($field->name) ."/". drupal_urlencode($value)) : check_plain($value);
}
}
return implode(', ', $fields);
......
......@@ -252,9 +252,9 @@ function profile_view_field($user, $field) {
case 'textarea':
return check_markup($value);
case 'selection':
return $browse ? l($value, "profile/$field->name/$value") : check_plain($value);
return $browse ? l($value, 'profile/'. drupal_urlencode($field->name) .'/'. drupal_urlencode($value)) : check_plain($value);
case 'checkbox':
return $browse ? l($field->title, "profile/$field->name") : check_plain($field->title);
return $browse ? l($field->title, 'profile/'. drupal_urlencode($field->name)) : check_plain($field->title);
case 'url':
return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
case 'date':
......@@ -273,7 +273,7 @@ function profile_view_field($user, $field) {
$fields = array();
foreach ($values as $value) {
if ($value = trim($value)) {
$fields[] = $browse ? l($value, "profile/". urlencode($field->name) ."/". urlencode($value)) : check_plain($value);
$fields[] = $browse ? l($value, "profile/". drupal_urlencode($field->name) ."/". drupal_urlencode($value)) : check_plain($value);
}
}
return implode(', ', $fields);
......
......@@ -811,7 +811,7 @@ function search_view() {
$type = 'node';
}
$keys = module_invoke($type, 'search', 'post', $_POST['edit']['keys']);
drupal_goto('search/'. urlencode($type) .'/'. urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
drupal_goto('search/'. drupal_urlencode($type) .'/'. drupal_urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
}
else if ($type == '') {
// Note: search/node can not be a default tab because it would take on the
......@@ -828,7 +828,7 @@ function search_view() {
watchdog('search',
t('Search: %keys (%type).', array('%keys' => theme('placeholder', $keys), '%type' => module_invoke($type, 'search', 'name'))),
WATCHDOG_NOTICE,
l(t('results'), 'search/'. urlencode($type) .'/'. urlencode($keys))
l(t('results'), 'search/'. drupal_urlencode($type) .'/'. drupal_urlencode($keys))
);
// Collect the search results:
......
......@@ -811,7 +811,7 @@ function search_view() {
$type = 'node';
}
$keys = module_invoke($type, 'search', 'post', $_POST['edit']['keys']);
drupal_goto('search/'. urlencode($type) .'/'. urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
drupal_goto('search/'. drupal_urlencode($type) .'/'. drupal_urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
}
else if ($type == '') {
// Note: search/node can not be a default tab because it would take on the
......@@ -828,7 +828,7 @@ function search_view() {
watchdog('search',
t('Search: %keys (%type).', array('%keys' => theme('placeholder', $keys), '%type' => module_invoke($type, 'search', 'name'))),
WATCHDOG_NOTICE,
l(t('results'), 'search/'. urlencode($type) .'/'. urlencode($keys))
l(t('results'), 'search/'. drupal_urlencode($type) .'/'. drupal_urlencode($keys))
);
// Collect the search results:
......
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