Hello. We are running into an issue when passing in URL parameters. When certain encoded characters are sent, the app fails to load, presenting a URI malformed error. Below is an example
http_s://domain.com?Param1=ssdfsd%8D
We discovered that when we replaced ? with # the app loaded correctly. Below is an example.
http_s://domain.com#Param1=ssdfsd%8D
Finally, it seems only to impact Windows-1252 encoded characters because all UTF8 encoding works great. Below is an example
http_s://domain.com?Param1=ssdfsd%C2%A2
We have found a workaround, but we are curious why we are experiencing this so we can prevent this behavior with future apps.
Thanks.
Hey @jessert Welcome to the community,
The issue you are encountering seems to stem from the difference in the way query parameters and hash parameters are handled in URLs.
-
Query Parameters: These parameters, which follow the ?
in the URL, must be properly URL-encoded. However, not all characters are valid in this context, and when invalid characters (like the character in your ssdfsd%8D
example) are included, it results in a URI malformed error.
-
Hash Parameters: In contrast, the #
character introduces hash parameters, which are generally more lenient with the characters they can accept. This may explain why your app loads correctly when using hash parameters to pass values.
The reason why you notice this issue specifically with Windows-1252 encoded characters could be related to how the browser interprets and encodes these characters when included in a query string. UTF-8 has a broader range of valid characters, which is why you see it working properly with encoded UTF-8 characters like ssdfsd%C2%A2
.
To prevent this behavior in the future:
-
Ensure Correct Encoding: Always ensure that any characters included in query parameters are properly URL-encoded. You may want to implement a check or normalization step in your application.
-
Prefer Hash Parameters: If you anticipate needing to use characters that may not be safely included in query parameters, consider using hash parameters as a fallback.
If you consistently encounter issues, providing thorough escaping of parameters before they are appended to the URL can help mitigate this problem.
1 Like