1
0
Fork 0

Encode spaces in paths to %20 instead of + (#140)

pull/38/merge
Felix Becker 2016-11-07 10:24:49 +01:00 committed by GitHub
parent 9e65cd4cf0
commit 47472252a7
2 changed files with 2 additions and 2 deletions

View File

@ -39,7 +39,7 @@ function pathToUri(string $filepath): string
if (substr($first, -1) !== ':') { if (substr($first, -1) !== ':') {
$first = urlencode($first); $first = urlencode($first);
} }
$parts = array_map('urlencode', $parts); $parts = array_map('rawurlencode', $parts);
array_unshift($parts, $first); array_unshift($parts, $first);
$filepath = implode('/', $parts); $filepath = implode('/', $parts);
return 'file:///' . $filepath; return 'file:///' . $filepath;

View File

@ -25,7 +25,7 @@ class FileUriTest extends TestCase
// special chars are escaped // special chars are escaped
$uri = pathToUri('c:/path/to/file/dürüm döner.php'); $uri = pathToUri('c:/path/to/file/dürüm döner.php');
$this->assertEquals('file:///c:/path/to/file/d%C3%BCr%C3%BCm+d%C3%B6ner.php', $uri); $this->assertEquals('file:///c:/path/to/file/d%C3%BCr%C3%BCm%20d%C3%B6ner.php', $uri);
//backslashes are transformed //backslashes are transformed
$uri = pathToUri('c:\\foo\\bar.baz'); $uri = pathToUri('c:\\foo\\bar.baz');