diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2022-03-13 19:37:45 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2022-03-13 19:37:45 +0100 |
commit | f4af532c5a8f37f69035616e2ae7908bf5b77a62 (patch) | |
tree | 90d2307d2d98972994229f5c2bc46ac56153e461 /boot.php | |
parent | 34ffff3947b8e89a667367277f0fde9c626fd143 (diff) | |
download | volse-hubzilla-f4af532c5a8f37f69035616e2ae7908bf5b77a62.tar.gz volse-hubzilla-f4af532c5a8f37f69035616e2ae7908bf5b77a62.tar.bz2 volse-hubzilla-f4af532c5a8f37f69035616e2ae7908bf5b77a62.zip |
Trim trailing & from query_string.
When trying to fetch an image file from the Cloud module, the default
nginx config will add a trailing & if there's no args specified.
Example:
https://example.com/cloud/username/some_image.png
This will be rewritten to:
https://example.com/index.php?q=/cloud/username/some_image.png&
This in turn will cause the Cloud module to try to redirect back to the
original because it does not match the query_string (in which the
ampersand has been converted to a question mark). And this will repeat
until the browser get's tired of it.
Diffstat (limited to 'boot.php')
-rw-r--r-- | boot.php | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -915,9 +915,14 @@ class App { if ((x($_SERVER, 'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") { self::$query_string = str_replace(['<', '>'], ['<', '>'], substr($_SERVER['QUERY_STRING'], 2)); + // removing trailing / - maybe a nginx problem if (substr(self::$query_string, 0, 1) == "/") self::$query_string = substr(self::$query_string, 1); + + // trim trailing '&' if no extra args are present + self::$query_string = rtrim(self::$query_string, '&'); + // change the first & to ? self::$query_string = preg_replace('/&/', '?', self::$query_string, 1); } |