Allow %-encoded colon after drive letter in URI
parent
f81d03948b
commit
66b5176a43
|
@ -56,5 +56,11 @@ function uriToPath(string $uri)
|
||||||
throw new InvalidArgumentException("Not a valid file URI: $uri");
|
throw new InvalidArgumentException("Not a valid file URI: $uri");
|
||||||
}
|
}
|
||||||
$filepath = urldecode($fragments['path']);
|
$filepath = urldecode($fragments['path']);
|
||||||
return strpos($filepath, ':') === false ? $filepath : str_replace('/', '\\', $filepath);
|
if (strpos($filepath, ':') !== false) {
|
||||||
|
if ($filepath[0] === '/') {
|
||||||
|
$filepath = substr($filepath, 1);
|
||||||
|
}
|
||||||
|
$filepath = str_replace('/', '\\', $filepath);
|
||||||
|
}
|
||||||
|
return $filepath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,12 @@ class FileUriTest extends TestCase
|
||||||
|
|
||||||
$uri = 'file:///c:/foo/bar.baz';
|
$uri = 'file:///c:/foo/bar.baz';
|
||||||
$this->assertEquals('c:\\foo\\bar.baz', uriToPath($uri));
|
$this->assertEquals('c:\\foo\\bar.baz', uriToPath($uri));
|
||||||
|
|
||||||
|
$uri = 'file:///c%3A/path/to/file/d%C3%BCr%C3%BCm+d%C3%B6ner.php';
|
||||||
|
$this->assertEquals('c:\\path\\to\\file\\dürüm döner.php', uriToPath($uri));
|
||||||
|
|
||||||
|
$uri = 'file:///c%3A/foo/bar.baz';
|
||||||
|
$this->assertEquals('c:\\foo\\bar.baz', uriToPath($uri));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUriToPathForUnknownProtocol()
|
public function testUriToPathForUnknownProtocol()
|
||||||
|
|
Loading…
Reference in New Issue