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

4.7.x
Steven Wittens 2005-10-21 11:14:55 +00:00
parent 6777fdb193
commit f31db8d70f
6 changed files with 23 additions and 11 deletions

View File

@ -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).
*

View File

@ -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')));

View File

@ -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);

View File

@ -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);

View File

@ -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:

View File

@ -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: