Skip to content

Commit

Permalink
Url::__construct: removed decoding of %xx entities in path [Closes #37]
Browse files Browse the repository at this point in the history
This is not a BC break, because partially reverts 24dd3cf.
  • Loading branch information
dg committed Dec 21, 2014
1 parent 7f301e1 commit a68edab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/Http/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']) : '';
Expand Down Expand Up @@ -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;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/Http/Url.httpScheme.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

0 comments on commit a68edab

Please sign in to comment.