Skip to content

Commit 09bcbb1

Browse files
authored
Fix #21: urldecode the path in DocumentRoot
Making sure that no null-bytes or slashes sneak into the path.
1 parent 3e9f57f commit 09bcbb1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/DocumentRoot.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,12 @@ public function setFallback(RequestHandler $requestHandler): void
114114
*/
115115
public function handleRequest(Request $request): Response
116116
{
117-
$path = removeDotPathSegments($request->getUri()->getPath());
117+
$path = $request->getUri()->getPath();
118+
if (stripos($path, "%2f") !== false || strpos($path, "%00") !== false) {
119+
return $this->respondFromFileInfo(Internal\FileInformation::fromNonExistentFile($path), $request);
120+
}
121+
122+
$path = removeDotPathSegments(\urldecode($path));
118123

119124
return ($fileInfo = $this->fetchCachedStat($path, $request))
120125
? $this->respondFromFileInfo($fileInfo, $request)

0 commit comments

Comments
 (0)