Commit b43fa0f9 authored by Steven Wittens's avatar Steven Wittens

- #41744: global urlencode() for menu paths

parent 3783e630
......@@ -963,6 +963,7 @@ function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
}
$path = drupal_get_path_alias($path);
$path = drupal_urlencode($path);
if (isset($fragment)) {
$fragment = '#'. $fragment;
......@@ -1251,13 +1252,15 @@ function drupal_implode_autocomplete($array) {
/**
* Wrapper around urlencode() which avoids Apache quirks.
*
* Should be used when placing arbitrary data inside the path of a clean URL.
* Should be used when placing arbitrary data in an URL. Note that Drupal paths
* are urlencoded() when passed through url() and do not require urlencoding()
* of individual components.
*
* @param $text
* String to encode
*/
function drupal_urlencode($text) {
return variable_get('clean_url', '0') ? str_replace('%2F', '/', urlencode($text)) : urlencode($text);
return str_replace('%2F', '/', urlencode($text));
}
/**
......
......@@ -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/'. drupal_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/'. $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')));
......
......@@ -146,7 +146,7 @@ function profile_menu($may_cache) {
function profile_browse() {
$name = arg(1);
$value = arg(2);
list(,,$value) = explode('/', $_GET['q'], 3);
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name));
......@@ -276,9 +276,9 @@ function profile_view_field($user, $field) {
case 'textarea':
return check_markup($value);
case 'selection':
return $browse ? l($value, 'profile/'. drupal_urlencode($field->name) .'/'. drupal_urlencode($value)) : check_plain($value);
return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
case 'checkbox':
return $browse ? l($field->title, 'profile/'. drupal_urlencode($field->name)) : check_plain($field->title);
return $browse ? l($field->title, 'profile/'. $field->name) : check_plain($field->title);
case 'url':
return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
case 'date':
......
......@@ -146,7 +146,7 @@ function profile_menu($may_cache) {
function profile_browse() {
$name = arg(1);
$value = arg(2);
list(,,$value) = explode('/', $_GET['q'], 3);
$field = db_fetch_object(db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_fields} WHERE name = '%s'", $name));
......@@ -276,9 +276,9 @@ function profile_view_field($user, $field) {
case 'textarea':
return check_markup($value);
case 'selection':
return $browse ? l($value, 'profile/'. drupal_urlencode($field->name) .'/'. drupal_urlencode($value)) : check_plain($value);
return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
case 'checkbox':
return $browse ? l($field->title, 'profile/'. drupal_urlencode($field->name)) : check_plain($field->title);
return $browse ? l($field->title, 'profile/'. $field->name) : check_plain($field->title);
case 'url':
return '<a href="'. check_url($value) .'">'. check_plain($value) .'</a>';
case 'date':
......
......@@ -165,7 +165,7 @@ function search_menu($may_cache) {
// To remember the user's search keywords when switching across tabs,
// we dynamically add the keywords to the search tabs' paths.
$keys = search_get_keys();
$keys = strlen($keys) ? '/'. drupal_urlencode($keys) : '';
$keys = strlen($keys) ? '/'. $keys : '';
foreach (module_list() as $name) {
if (module_hook($name, 'search') && $title = module_invoke($name, 'search', 'name')) {
$items[] = array('path' => 'search/'. $name . $keys, 'title' => $title,
......@@ -881,7 +881,7 @@ function search_view() {
$type = 'node';
}
$keys = module_invoke($type, 'search', 'post', $_POST['edit']['keys']);
drupal_goto('search/'. drupal_urlencode($type) .'/'. drupal_urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
drupal_goto('search/'. $type .'/'. (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
......@@ -898,7 +898,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/'. drupal_urlencode($type) .'/'. drupal_urlencode($keys))
l(t('results'), 'search/'. $type .'/'. $keys)
);
// Collect the search results:
......
......@@ -165,7 +165,7 @@ function search_menu($may_cache) {
// To remember the user's search keywords when switching across tabs,
// we dynamically add the keywords to the search tabs' paths.
$keys = search_get_keys();
$keys = strlen($keys) ? '/'. drupal_urlencode($keys) : '';
$keys = strlen($keys) ? '/'. $keys : '';
foreach (module_list() as $name) {
if (module_hook($name, 'search') && $title = module_invoke($name, 'search', 'name')) {
$items[] = array('path' => 'search/'. $name . $keys, 'title' => $title,
......@@ -881,7 +881,7 @@ function search_view() {
$type = 'node';
}
$keys = module_invoke($type, 'search', 'post', $_POST['edit']['keys']);
drupal_goto('search/'. drupal_urlencode($type) .'/'. drupal_urlencode(is_null($keys) ? $_POST['edit']['keys'] : $keys));
drupal_goto('search/'. $type .'/'. (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
......@@ -898,7 +898,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/'. drupal_urlencode($type) .'/'. drupal_urlencode($keys))
l(t('results'), 'search/'. $type .'/'. $keys)
);
// Collect the search results:
......
......@@ -1044,9 +1044,6 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
drupal_not_found();
}
// Needed for '+' to show up in RSS discovery URLs
$rss_tids = urlencode($str_tids);
if ($tids) {
$result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (%s)', 't', 'tid'), implode(',', $tids));
$tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
......@@ -1074,10 +1071,10 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
drupal_add_link(array('rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => 'RSS - '. $title,
'href' => url('taxonomy/term/'. $rss_tids .'/'. $depth .'/feed')));
'href' => url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed')));
$output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE));
$output .= theme('xml_icon', url("taxonomy/term/$rss_tids/$depth/feed"));
$output .= theme('xml_icon', url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed'));
return $output;
break;
......
......@@ -1044,9 +1044,6 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
drupal_not_found();
}
// Needed for '+' to show up in RSS discovery URLs
$rss_tids = urlencode($str_tids);
if ($tids) {
$result = db_query(db_rewrite_sql('SELECT t.tid, t.name FROM {term_data} t WHERE t.tid IN (%s)', 't', 'tid'), implode(',', $tids));
$tids = array(); // we rebuild the $tids-array so it only contains terms the user has access to.
......@@ -1074,10 +1071,10 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
drupal_add_link(array('rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => 'RSS - '. $title,
'href' => url('taxonomy/term/'. $rss_tids .'/'. $depth .'/feed')));
'href' => url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed')));
$output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE));
$output .= theme('xml_icon', url("taxonomy/term/$rss_tids/$depth/feed"));
$output .= theme('xml_icon', url('taxonomy/term/'. $str_tids .'/'. $depth .'/feed'));
return $output;
break;
......
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