Permalink
Browse files

No problem find with parse_url

  • Loading branch information...
1 parent fe85a4a commit 0a4feed160785e6bcbd353f690fd7b18cd7c0fb5 @stefanneculai committed Mar 29, 2012
Showing with 13 additions and 30 deletions.
  1. +1 −30 libraries/joomla/string/string.php
  2. +12 −0 tests/suites/unit/joomla/string/JStringTest.php
@@ -958,35 +958,6 @@ public static function compliant($str)
*/
public static function parse_url($url)
{
-
- $result = array();
-
- // Build arrays of values we need to decode before parsing
- $entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B',
- '%5D');
- $replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "$", ",", "/", "?", "%", "#", "[", "]");
-
- // Create encoded URL with special URL characters decoded so it can be parsed
- // All other characters will be encoded
- $encodedURL = str_replace($entities, $replacements, urlencode($url));
-
- // Parse the encoded URL
- $encodedParts = parse_url($encodedURL);
-
- // Now, decode each value of the resulting array
- foreach ($encodedParts as $key => $value)
- {
- if ($key == 'path' || $key == 'fragment')
- {
- $result[$key] = urldecode($value);
- }
- else
- {
- $result[$key] = $value;
- }
- }
-
- return $result;
-
+ return parse_url($url);
}
}
@@ -651,5 +651,17 @@ public function testParse_Url()
$expected = parse_url($url);
$actual = JString::parse_url($url);
$this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal');
+
+ // Test wrong url
+ $url = 'http://a.com/?a=é';
+ $expected = parse_url($url);
+ $actual = JString::parse_url($url);
+ $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal');
+
+ // Test wrong url
+ $url = 'ftp://user:abcé@example.com/';
+ $expected = parse_url($url);
+ $actual = JString::parse_url($url);
+ $this->assertEquals($expected, $actual, 'Line: ' . __LINE__ . ' Results should be equal');
}
}

0 comments on commit 0a4feed

Please sign in to comment.