-
-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Query params replacing space (%20) with underscore (_) #2213
Comments
Yeah, I can reproduce that. That's weird. I'll check why this is happening. |
Some additional information on this bug. A subset of percent encoded characters in parameters are being replaced with the non-percent encoded versions. This replacement does not happen if the percent encoded character is in the URL that is being shortened. Here is a test sample:
Space and period are placed with underscore, but others seem to be replaced with the correct equivalent character. I don't see any particulate logic to what is or is not being replaced. |
So, I have been investigating this, and at first I didn't realize you were setting spaces in the parameter names. If you set them in the values, it works as expected. The reason this is happening is because, for historical reasons, PHP ensures query parameter names are valid variable names, because they get promoted as variables. That implies spaces are converted to underscores (see the first example here https://www.php.net/manual/en/function.parse-str.php), but there are other conversions as you found. And the reason the query string needs to be parsed is because Shlink needs to merge the query params to be forwarded, with any potential query param in the long URL. So for example, if the short URL is Additionally, there are some special query params that are stripped, etc. So Shlink needs to parse the raw query strings, apply some logic, and serialize the query string back. However, I have access to the raw query string as well, so I could try to apply some custom deserialization logic that prevents this behavior and preserves query param names verbatim. |
This should now be fixed. I'll release v4.2.2 soon. |
I have just released Shlink 4.2.2 which includes the fix for this. |
This update is working as expected. Thank you! |
Shlink version
4.2.1
PHP version
8.3.12
How do you serve Shlink
Docker image
Database engine
PostgreSQL
Database version
13.9
Current behavior
Spaces in query parameters are replaced by underscores.
For example,
https://internal.fqdn/F4UVN?spaces are valid=true
redirects tohttp://www.example.com/?spaces_are_valid=true
(note the underscores instead of spaces)
Expected behavior
Spaces need to be preserved in the query parameters.
For example, in Tableau, query parameters can be used to set filters on the linked dashboard, but most filters contain spaces in their names. When the spaces are changed to underscores, it breaks the filtering.
Minimum steps to reproduce
http://www.example.com
is good since it doesn't do anything with query parameters).Forward query params on redirect
is enabled.?Some Filter=1
)?Some_Filter=1
)The text was updated successfully, but these errors were encountered: