From a68edab12b1317cf5956ea78ede01bcde91ed976 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sun, 21 Dec 2014 17:34:51 +0100 Subject: [PATCH] Url::__construct: removed decoding of %xx entities in path [Closes #37] This is not a BC break, because partially reverts 24dd3cf00. --- src/Http/Url.php | 4 ++-- tests/Http/Url.httpScheme.phpt | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Http/Url.php b/src/Http/Url.php index 039d1724..a9fc93c3 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -100,7 +100,7 @@ public function __construct($url = NULL) $this->host = isset($p['host']) ? rawurldecode($p['host']) : ''; $this->user = isset($p['user']) ? rawurldecode($p['user']) : ''; $this->pass = isset($p['pass']) ? rawurldecode($p['pass']) : ''; - $this->path = isset($p['path']) ? self::unescape($p['path'], '%/') + $this->path = isset($p['path']) ? $p['path'] : (in_array($this->scheme, array('http', 'https'), TRUE) ? '/' : ''); $this->query = isset($p['query']) ? self::unescape($p['query'], '%&;=+ ') : ''; $this->fragment = isset($p['fragment']) ? rawurldecode($p['fragment']) : ''; @@ -422,7 +422,7 @@ public function isEqual($url) && $url->port === $this->port && ($http || $url->user === $this->user) && ($http || $url->pass === $this->pass) - && $url->path === $this->path + && self::unescape($url->path, '%/') === self::unescape($this->path, '%/') && $query === $query2 && $url->fragment === $this->fragment; } diff --git a/tests/Http/Url.httpScheme.phpt b/tests/Http/Url.httpScheme.phpt index c83c207a..8734ad4c 100644 --- a/tests/Http/Url.httpScheme.phpt +++ b/tests/Http/Url.httpScheme.phpt @@ -13,21 +13,21 @@ require __DIR__ . '/../bootstrap.php'; $url = new Url('http://username%3A:password%3A@hostn%61me:60/p%61th/script.php?%61rg=value#%61nchor'); -Assert::same( 'http://hostname:60/path/script.php?arg=value#anchor', (string) $url ); +Assert::same( 'http://hostname:60/p%61th/script.php?arg=value#anchor', (string) $url ); Assert::same( 'http', $url->scheme ); Assert::same( 'username:', $url->user ); Assert::same( 'password:', $url->password ); Assert::same( 'hostname', $url->host ); Assert::same( 60, $url->port ); -Assert::same( '/path/script.php', $url->path ); -Assert::same( '/path/', $url->basePath ); +Assert::same( '/p%61th/script.php', $url->path ); +Assert::same( '/p%61th/', $url->basePath ); Assert::same( 'arg=value', $url->query ); Assert::same( 'anchor', $url->fragment ); Assert::same( 'hostname:60', $url->authority ); Assert::same( 'http://hostname:60', $url->hostUrl ); -Assert::same( 'http://hostname:60/path/script.php?arg=value#anchor', $url->absoluteUrl ); -Assert::same( 'http://hostname:60/path/', $url->baseUrl ); +Assert::same( 'http://hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl ); +Assert::same( 'http://hostname:60/p%61th/', $url->baseUrl ); Assert::same( 'script.php?arg=value#anchor', $url->relativeUrl ); $url->scheme = NULL; -Assert::same( '//username%3A:password%3A@hostname:60/path/script.php?arg=value#anchor', $url->absoluteUrl ); +Assert::same( '//username%3A:password%3A@hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl );