From eda4a2c116750cbefb9d2d4e9164c883d71315cf Mon Sep 17 00:00:00 2001 From: nobody Date: Tue, 3 Aug 2021 17:12:28 -0700 Subject: [PATCH] include/network:get_request_string() ignore fragments --- include/network.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/network.php b/include/network.php index 0d2ebe50a..8d82e4f55 100644 --- a/include/network.php +++ b/include/network.php @@ -1854,16 +1854,22 @@ function is_https_request() { } /** - * @brief Given a URL, return everything after the host portion. + * @brief Given a URL, return everything after the host portion, but exclude any fragments. * example https://foobar.com/gravy?g=5&y=6 * returns /gravy?g=5&y=6 + * example https:://foobar.com/gravy?g=5&y=6#fragment + * also returns /gravy?g=5&y=6 * result always returns the leading slash */ function get_request_string($url) { - $a = explode('/',$url,4); - return '/' . ((count($a) > 3) ? $a[3] : EMPTY_STR); + $m = parse_url($url); + if ($m) { + return ( (isset($m['path']) ? $m['path'] : '/' ) . (isset($m['query']) ? '?' . $m['query'] : EMPTY_STR) ); + } + + return EMPTY_STR; }