You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have encountered issues with unsafe URL path parameters that require URL encoding and decoding. Unfortunately, the auto_route library complicates this process. Here are the findings from our investigation:
By default, path parameters are not URL encoded or configured for encoding. Even when I manually encode the path parameters, it fails to work properly; they are consistently URL decoded, often inappropriately.
At line 134, the path should be split before decoding. The decoded segments should be used solely as values for path parameters, rather than influencing the RouteMatch. Currently, the URL path is always converted to its URL-decoded version, which is incorrect. According to RFC 3986, section 2.2, URL-decoded characters should not be treated as their reserved equivalents.
final matchedPath =Uri.encodeFull(matchedUrlState.path);
It would be better is if path/query params are url encoded by default or config when navigating using PageRouteInfo. Then param maps are stored raw (non-encoded). When parsing/matching URLs, only the path params map are url decoded.
Hopefully this would be fixed soon. I'd make a PR but it'll take time, especially to test & validate.
The text was updated successfully, but these errors were encountered:
We have encountered issues with unsafe URL path parameters that require URL encoding and decoding. Unfortunately, the auto_route library complicates this process. Here are the findings from our investigation:
By default, path parameters are not URL encoded or configured for encoding. Even when I manually encode the path parameters, it fails to work properly; they are consistently URL decoded, often inappropriately.
At line 134, the path should be split before decoding. The decoded segments should be used solely as values for path parameters, rather than influencing the RouteMatch. Currently, the URL path is always converted to its URL-decoded version, which is incorrect. According to RFC 3986, section 2.2, URL-decoded characters should not be treated as their reserved equivalents.
auto_route_library/auto_route/lib/src/matcher/route_matcher.dart
Lines 132 to 173 in 7a03a88
Additionally, UrlState is also consistently URL decoded, as seen here
auto_route_library/auto_route/lib/src/router/parser/route_information_parser.dart
Line 124 in 7a03a88
The only instance where URL encoding occurs is in auto_router_delegate.dart, and only for deep links.
auto_route_library/auto_route/lib/src/router/controller/auto_router_delegate.dart
Line 164 in 7a03a88
It would be better is if path/query params are url encoded by default or config when navigating using PageRouteInfo. Then param maps are stored raw (non-encoded). When parsing/matching URLs, only the path params map are url decoded.
Hopefully this would be fixed soon. I'd make a PR but it'll take time, especially to test & validate.
The text was updated successfully, but these errors were encountered: