joomla/joomla-platform — Issue #834: Bug in JString::parse_url
Author: ebitester1
Created: 2012-02-07 18:52:43+00:00
State: open

Try this:

$url = 'http://a.com/b.php?retUrl='.rawurlencode('http://a.com/b.php?a=123&b=456');

echo '

';
echo "url: $url\n\n";

echo "JString::parse_url():\n";
$parts = JString::parse_url($url);
parse_str($parts['query'], $parts['vars']);
print_r($parts);

echo "native parse_url():\n";
$parts = parse_url($url);
parse_str($parts['query'], $parts['vars']);
print_r($parts);

echo '

';

Output:

url: http://a.com/b.php?retUrl=http%3A%2F%2Fa.com%2Fb.php%3Fa%3D123%26b%3D456

JString::parse_url():
Array
(
[scheme] => http
[host] => a.com
[path] => /b.php
[query] => retUrl=http://a.com/b.php?a=123&b=456 // WRONG
[vars] => Array
(
[retUrl] => http://a.com/b.php?a=123 // WRONG
[b] => 456 // WRONG
)

)
native parse_url():
Array
(
[scheme] => http
[host] => a.com
[path] => /b.php
[query] => retUrl=http%3A%2F%2Fa.com%2Fb.php%3Fa%3D123%26b%3D456 // CORRECT
[vars] => Array
(
[retUrl] => http://a.com/b.php?a=123&b=456 // CORRECT
)

)