Skip to content

Commit f60e62e

Browse files
committed
Suppress undefined index errors more carefully
1 parent f05a32f commit f60e62e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

phpserver/router.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
$path = pathinfo($_SERVER["SCRIPT_FILENAME"]);
4848
$url = pathinfo(substr($_SERVER["REQUEST_URI"], 1));
4949
$route = parse_url(substr($_SERVER["REQUEST_URI"], 1))["path"];
50-
$ext = @pathinfo($route)['extension'];
50+
$pathinfo = pathinfo($route);
51+
$ext = isset($pathinfo['extension']) ? $pathinfo['extension'] : '';
5152

5253
if ($path["basename"] == 'favicon.ico') {
5354
return false;
@@ -95,7 +96,7 @@
9596
'html' => 'text/html',
9697
];
9798

98-
$type = @$mimeTypes[$ext];
99+
$type = isset($mimeTypes[$ext]) && $mimeTypes[$ext];
99100
if ($type) {
100101
header("Content-Type: $type");
101102
}

0 commit comments

Comments
 (0)