Skip to content

fix(router): decode '+' as space in URL query strings#5388

Open
mango766 wants to merge 1 commit intoDioxusLabs:mainfrom
mango766:fix/query-plus-as-space
Open

fix(router): decode '+' as space in URL query strings#5388
mango766 wants to merge 1 commit intoDioxusLabs:mainfrom
mango766:fix/query-plus-as-space

Conversation

@mango766
Copy link

Summary

Fixes #5280

The Dioxus router currently uses percent_decode_str to decode query strings, but this only handles %XX-style percent encoding. Per the application/x-www-form-urlencoded spec, + is a valid encoding for space in query strings. Some services (e.g. Facebook Messenger) rewrite %20 to + when processing URLs, causing the router to pass through the literal + character.

This PR replaces + with space in the query string before percent-decoding, matching the expected URL behavior.

Changes

  • packages/router-macro/src/lib.rs: In the generated FromStr implementation, replace + with space in the query string before calling percent_decode_str
  • packages/router/tests/parsing.rs: Added query_plus_decoded_as_space test verifying + is decoded as space, %20 still works, and multiple + signs are handled

Example

Before: /?query=Shis+Kebap → query = "Shis+Kebap" ❌
After:  /?query=Shis+Kebap → query = "Shis Kebap" ✅

Per the application/x-www-form-urlencoded spec, '+' is a valid
encoding for space in query strings. Some services (e.g. Facebook
Messenger) rewrite '%20' to '+' when processing URLs, which caused
the router to pass through the literal '+' character instead of
decoding it as a space.

This replaces '+' with space before percent-decoding the query
string, matching the behavior expected by the URL spec.

Fixes DioxusLabs#5280
@mango766 mango766 requested a review from a team as a code owner March 19, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dioxus Router fails to parse + in URL query string

1 participant