Skip to content

Commit

Permalink
Add more tests and fix crazy php bugs - https://bugs.php.net/bug.php?…
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Aug 3, 2017
1 parent eea26de commit 6e219ec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/private/AppFramework/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,11 @@ public function getRequestUri() {
$uri = $this->getScriptName() . substr($uri, strlen($this->server['SCRIPT_NAME']));
} else {
$components = parse_url($uri);
if ($components === false) {
// due to https://bugs.php.net/bug.php?id=70942 we have to add a
// fake schema and host to successfully extract path, query and fragment
$components = parse_url("http://localhost$uri");
}
$uri = $components['path'];
if (isset($components['query'])) {
$uri .= '?'.$components['query'];
Expand Down
21 changes: 18 additions & 3 deletions tests/lib/AppFramework/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,22 @@ public function pathInfoProvider() {
];
}

public function testGetRequestUriWithoutOverwrite() {
public function providesUri() {
return[
['/test.php', '/test.php'],
['/remote.php/dav/files/user0/test_folder:5', '/remote.php/dav/files/user0/test_folder:5'],
['/remote.php/dav/files/admin/welcome.txt', 'http://localhost:8080/remote.php/dav/files/admin/welcome.txt'],
['/path?arg=value#anchor', 'http://username:password@hostname:9090/path?arg=value#anchor'],
['/path:5?arg=value#anchor', 'http://username:password@hostname:9090/path:5?arg=value#anchor'],
['', ''],
['/test.php', '/test.php'],
];
}

/**
* @dataProvider providesUri
*/
public function testGetRequestUriWithoutOverwrite($expectedUri, $requestUri) {
$this->config
->expects($this->once())
->method('getSystemValue')
Expand All @@ -1276,7 +1291,7 @@ public function testGetRequestUriWithoutOverwrite() {
$request = new Request(
[
'server' => [
'REQUEST_URI' => '/test.php'
'REQUEST_URI' => $requestUri
]
],
$this->secureRandom,
Expand All @@ -1285,7 +1300,7 @@ public function testGetRequestUriWithoutOverwrite() {
$this->stream
);

$this->assertSame('/test.php', $request->getRequestUri());
$this->assertSame($expectedUri, $request->getRequestUri());
}

public function providesGetRequestUriWithOverwriteData() {
Expand Down

0 comments on commit 6e219ec

Please sign in to comment.