Privilege matching -- allow JS anchors. Fixes #9550

Attempts to detect a special case where a file does not actually
exist, and yet should be allowed since it is used by JavaScript.

So long as the anchor name doesn't contain any characters that might let
it evade other checks, allow it through.
This commit is contained in:
jim-p 2019-05-24 15:47:43 -04:00
parent 42c48efe1c
commit bdbd8534ee

View File

@ -42,6 +42,16 @@ function cmp_page_matches($page, & $matches, $fullwc = true) {
$file = realpath( $g['www_path'] . '/' . ltrim($file, '/'));
if (empty($file)) {
/* File does not exist, or other path shenanigans */
/* Some tabs are just JS anchors, detect this case. */
if ((substr($page, 0, 1) == "#") &&
(strpos($page, '.') === false) &&
(strpos($page, '/') === false) &&
(strpos($page, '?') === false)) {
return true;
}
/* Tried to query a path that does not exist */
return false;
}
$page = str_replace($g['www_path'] . '/', '', $file);