Skip to content

Commit 44779a0

Browse files
authored
Merge pull request #256 from nbayramberdiyev/fix/encode-special-characters
Encode special characters
2 parents bc6f29e + e03b42a commit 44779a0

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

src/Factory/UriFactory.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ public function createFromGlobals(array $globals): Uri
9494
}
9595

9696
// Query string
97-
$queryString = '';
98-
if (isset($globals['QUERY_STRING'])) {
99-
$queryString = $globals['QUERY_STRING'];
100-
}
97+
$queryString = $globals['QUERY_STRING'] ?? '';
10198

10299
// Request URI
103100
$requestUri = '';

src/Uri.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ public function __construct(
8787
$this->path = $this->filterPath($path);
8888
$this->query = $this->filterQuery($query);
8989
$this->fragment = $this->filterFragment($fragment);
90-
$this->user = $user;
91-
$this->password = $password;
90+
$this->user = $this->filterUserInfo($user);
91+
$this->password = $this->filterUserInfo($password);
9292
}
9393

9494
/**

tests/Factory/UriFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function testGetUserInfoWithUsernameAndPasswordEncodesCorrectly()
5353
{
5454
$uri = $this
5555
->createUriFactory()
56-
->createUri('https://bob%40example.com:pass%3Aword@example.com:443/foo/bar?abc=123#section3');
56+
->createUri('https://bob@example.com:pass:word@example.com:443/foo/bar?abc=123#section3');
5757

5858
$this->assertEquals('bob%40example.com:pass%3Aword', $uri->getUserInfo());
5959
}

0 commit comments

Comments
 (0)