Commit 087a54a6 authored by Dries's avatar Dries

- Patch #578520 by sun, c960657 | mfb, Dries, catch, mattyoung: Changed Make ...

- Patch #578520 by sun, c960657 | mfb, Dries, catch, mattyoung: Changed Make  in url() only accept an array.
parent 67e96428
......@@ -520,8 +520,11 @@ function drupal_parse_url($url) {
}
// Internal URLs.
else {
$parts = parse_url($url);
$options['path'] = $parts['path'];
// parse_url() does not support relative URLs, so make it absolute. E.g. the
// relative URL "foo/bar:1" isn't properly parsed.
$parts = parse_url('http://example.com/' . $url);
// Strip the leading slash that was just added.
$options['path'] = substr($parts['path'], 1);
if (isset($parts['query'])) {
parse_str($parts['query'], $options['query']);
}
......
......@@ -94,6 +94,15 @@ class CommonURLUnitTest extends DrupalUnitTestCase {
);
$this->assertEqual(drupal_parse_url($url), $result, t('Relative URL parsed correctly.'));
// Relative URL that is known to confuse parse_url().
$url = 'foo/bar:1';
$result = array(
'path' => 'foo/bar:1',
'query' => array(),
'fragment' => '',
);
$this->assertEqual(drupal_parse_url($url), $result, t('Relative URL parsed correctly.'));
// Absolute URL.
$url = '/foo/bar?foo=bar&bar=baz&baz#foo';
$result = array(
......
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