fix CSRF, try fix %20

This commit is contained in:
root
2021-10-06 08:01:31 +00:00
parent 76249edf4d
commit 9205015782
9 changed files with 135 additions and 51 deletions
+11 -3
View File
@@ -37,13 +37,20 @@ function GetPathSetting($event, $context)
$_SERVER['region'] = $context['region'];
$_SERVER['service_name'] = $context['service']['name'];
$_SERVER['function_name'] = $context['function']['name'];
$path = urldecode($event['path']);
//$path = str_replace('%5D', ']', str_replace('%5B', '[', $event['path']));//%5B
//$path = $event['path'];
$path = $event['requestURI'];
if (strpos($path, '?')) $path = substr($path, 0, strpos($path, '?'));
$tmp = urldecode($event['requestURI']);
if (strpos($tmp, '?')) $tmp = substr($tmp, 0, strpos($tmp, '?'));
if ($path=='/'||$path=='') {
$_SERVER['base_path'] = $tmp;
} else {
$_SERVER['base_path'] = substr($tmp, 0, strlen($tmp)-strlen($path)+1);
while ($tmp!=urldecode($tmp)) $tmp = urldecode($tmp);
$tmp1 = urldecode($event['path']);
while ($tmp1!=urldecode($tmp1)) $tmp1 = urldecode($tmp1);
$_SERVER['base_path'] = substr($tmp, 0, strlen($tmp)-strlen($tmp1)+1);
//$_SERVER['base_path'] = substr($tmp, 0, strlen(urldecode($event['path'])));
}
$_SERVER['base_path'] = spurlencode($_SERVER['base_path'], '/');
@@ -63,7 +70,8 @@ function GetPathSetting($event, $context)
$_SERVER['referhost'] = explode('/', $event['headers']['Referer'][0])[2];
$_SERVER['HTTP_IF_MODIFIED_SINCE'] = $event['headers']['If-Modified-Since'][0];
$_SERVER['FC_SERVER_PATH'] = '/var/fc/runtime/php7.2';
return spurlencode($path, '/');
return $path;
//return spurlencode($path, '/');
}
function getConfig($str, $disktag = '')