Skip to content

Commit a68edab

Browse files
committed
Url::__construct: removed decoding of %xx entities in path [Closes #37]
This is not a BC break, because partially reverts 24dd3cf.
1 parent 7f301e1 commit a68edab

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/Http/Url.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function __construct($url = NULL)
100100
$this->host = isset($p['host']) ? rawurldecode($p['host']) : '';
101101
$this->user = isset($p['user']) ? rawurldecode($p['user']) : '';
102102
$this->pass = isset($p['pass']) ? rawurldecode($p['pass']) : '';
103-
$this->path = isset($p['path']) ? self::unescape($p['path'], '%/')
103+
$this->path = isset($p['path']) ? $p['path']
104104
: (in_array($this->scheme, array('http', 'https'), TRUE) ? '/' : '');
105105
$this->query = isset($p['query']) ? self::unescape($p['query'], '%&;=+ ') : '';
106106
$this->fragment = isset($p['fragment']) ? rawurldecode($p['fragment']) : '';
@@ -422,7 +422,7 @@ public function isEqual($url)
422422
&& $url->port === $this->port
423423
&& ($http || $url->user === $this->user)
424424
&& ($http || $url->pass === $this->pass)
425-
&& $url->path === $this->path
425+
&& self::unescape($url->path, '%/') === self::unescape($this->path, '%/')
426426
&& $query === $query2
427427
&& $url->fragment === $this->fragment;
428428
}

tests/Http/Url.httpScheme.phpt

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ require __DIR__ . '/../bootstrap.php';
1313

1414
$url = new Url('http://username%3A:password%3A@hostn%61me:60/p%61th/script.php?%61rg=value#%61nchor');
1515

16-
Assert::same( 'http://hostname:60/path/script.php?arg=value#anchor', (string) $url );
16+
Assert::same( 'http://hostname:60/p%61th/script.php?arg=value#anchor', (string) $url );
1717
Assert::same( 'http', $url->scheme );
1818
Assert::same( 'username:', $url->user );
1919
Assert::same( 'password:', $url->password );
2020
Assert::same( 'hostname', $url->host );
2121
Assert::same( 60, $url->port );
22-
Assert::same( '/path/script.php', $url->path );
23-
Assert::same( '/path/', $url->basePath );
22+
Assert::same( '/p%61th/script.php', $url->path );
23+
Assert::same( '/p%61th/', $url->basePath );
2424
Assert::same( 'arg=value', $url->query );
2525
Assert::same( 'anchor', $url->fragment );
2626
Assert::same( 'hostname:60', $url->authority );
2727
Assert::same( 'http://hostname:60', $url->hostUrl );
28-
Assert::same( 'http://hostname:60/path/script.php?arg=value#anchor', $url->absoluteUrl );
29-
Assert::same( 'http://hostname:60/path/', $url->baseUrl );
28+
Assert::same( 'http://hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl );
29+
Assert::same( 'http://hostname:60/p%61th/', $url->baseUrl );
3030
Assert::same( 'script.php?arg=value#anchor', $url->relativeUrl );
3131

3232
$url->scheme = NULL;
33-
Assert::same( '//username%3A:password%3A@hostname:60/path/script.php?arg=value#anchor', $url->absoluteUrl );
33+
Assert::same( '//username%3A:password%3A@hostname:60/p%61th/script.php?arg=value#anchor', $url->absoluteUrl );

0 commit comments

Comments
 (0)