make_self_url: properly strip out GET params

This commit is contained in:
Andrew Dolgov 2022-07-24 14:50:03 +03:00
parent 8cf421e1fc
commit 74d7f88fae
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
1 changed files with 3 additions and 1 deletions

View File

@ -465,9 +465,11 @@ class Config {
/** generates reference self_url_path (no trailing slash) */ /** generates reference self_url_path (no trailing slash) */
static function make_self_url() : string { static function make_self_url() : string {
$proto = self::is_server_https() ? 'https' : 'http'; $proto = self::is_server_https() ? 'https' : 'http';
$self_url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
$self_url_path = $proto . '://' . $_SERVER["HTTP_HOST"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
$self_url_path = preg_replace("/\w+\.php(\?.*$)?$/", "", $self_url_path); $self_url_path = preg_replace("/\w+\.php(\?.*$)?$/", "", $self_url_path);
#$self_url_path = preg_replace("/(\?.*$)?$/", "", $self_url_path);
if (substr($self_url_path, -1) === "/") { if (substr($self_url_path, -1) === "/") {
return substr($self_url_path, 0, -1); return substr($self_url_path, 0, -1);