Commit f4d2e2f0 authored by John Fiala's avatar John Fiala
Browse files

Issue #1616752 by Taran2L:Period in names of querystring items was being replaced with underscores.

parent a81a4c91
......@@ -578,20 +578,44 @@ function _link_parse_url($url) {
// Separate out the query string, if any.
if (strpos($url, '?') !== FALSE) {
$query = substr($url, strpos($url, '?') + 1);
parse_str($query, $query_array);
// See http://drupal.org/node/1710578
foreach ($query_array as $key=> &$value) {
if ($value === '' && FALSE === strpos($query, $key . '=')) {
$value = NULL;
}
}
$url_parts['query'] = $query_array;
$url_parts['query'] = _link_parse_str($query);
$url = substr($url, 0, strpos($url, '?'));
}
$url_parts['url'] = $url;
return $url_parts;
}
/**
* Bacause parse_str replaces the following characters in query parameters name
* in order to maintain compability with deprecated register_globals directive:
*
* - chr(32) ( ) (space)
* - chr(46) (.) (dot)
* - chr(91) ([) (open square bracket)
* - chr(128) - chr(159) (various)
*
* @param string $query
* Query to parse.
*
* @return Array
* Array of query parameters.
*
* @see http://php.net/manual/en/language.variables.external.php#81080
*/
function _link_parse_str($query) {
$query_array = array();
$pairs = explode('&', $query);
foreach ($pairs as $pair) {
$name_value = explode('=', $pair);
$name = urldecode($name_value[0]);
$value = isset($name_value[1]) ? urldecode($name_value[1]) : NULL;
$query_array[$name] = $value;
}
return $query_array;
}
/**
* Implements hook_theme().
*/
......
......@@ -104,18 +104,24 @@ class LinkUITest extends DrupalWebTestcase {
'msg' => 'js label',
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
),
array(
array(
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
'msg' => 'js label',
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
),
array(
array(
'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
'label' => $this->randomName(),
'msg' => 'js url',
'type' => self::LINK_INPUT_TYPE_BAD_URL
),
array(
'href' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
'label' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
'msg' => 'Url with . in querystring',
'type' => self::LINK_INPUT_TYPE_GOOD,
),
);
$test_case = array(
'href' => 'www.example.com/'. $this->randomName(),
......
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