-
Notifications
You must be signed in to change notification settings - Fork 594
core: percent encode illegal chars when creating URI query #3003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test FAILed. Pull request validation reportFailed Test SuitesTest result for 'akka-http2-support / Pr-validation / ./ executeTests' Mima Failures |
|
Test FAILed. Pull request validation reportMima Failures |
ignasi35
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
(I'm confused why Jenkins is reporting mima failures, AFAICS those should be filtered out now..) |
jrudolph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable. Thanks for digging into this rabbit hole. A few small things below
...ore/src/main/mima-filters/10.1.x.backwards.excludes/query-string-encoding.backwards.excludes
Outdated
Show resolved
Hide resolved
| uri.withQuery(Query(Map("param1" -> "value1"))) shouldEqual Uri("http://host/path?param1=value1#fragment") | ||
| uri.withRawQueryString("param1=value1") shouldEqual Uri("http://host/path?param1=value1#fragment") | ||
|
|
||
| uri.withQuery(Query("param1" -> "val\"ue1")) shouldEqual Uri("http://host/path?param1=val%22ue1#fragment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, this API should definitely encode when converting to raw 👍
akka-http-core/src/test/scala/akka/http/scaladsl/model/UriSpec.scala
Outdated
Show resolved
Hide resolved
akka-http-tests/src/test/java/akka/http/javadsl/server/directives/ParameterDirectivesTest.java
Show resolved
Hide resolved
|
Test FAILed. Pull request validation reportMima Failures |
|
Test FAILed. Pull request validation reportMima Failures |
Co-Authored-By: Ignasi Marimon-Clos <ignasi@lightbend.com>
Co-Authored-By: Enno <458526+ennru@users.noreply.github.com>
…http into encode-query-string-on-render
|
Test PASSed. |
jrudolph
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work, thanks.
Do you think you have now closed all loopholes to create Uris with an invalid rawQueryString? AFAICS, it now looks fine. copy goes through the safe variant. From Java you could create an unexpected subclass of sealed scaladsl.model.Uri but let's not worry about that one.
akka-http-tests/src/test/java/akka/http/javadsl/server/directives/ParameterDirectivesTest.java
Show resolved
Hide resolved
Yes, I think so - of course there's a couple of situations where we parse the string again to make sure there are no invalid percent-encodings in there, but no longer in the 'hot path'. |
Yeah, good point. If someone cares about those paths they can still be optimized later on. |
This makes sure 'strict' parsing of the Uri query string only allows characters that are actually allowed here by the RFC. It does not change the fact that Uri's rawQueryString is the percent-encoded representation of the query string, since this information is needed to parse it into a key-value structure. When parsing the Uri in 'relaxed' mode or constructing programmatically, we do accept characters that are not allowed, but percent-encode any would-be invalid characters. API's that can be used to programmatically add or modify the query string are adapted to not accept invalid percent-encoded values (e.g. %x2) and convert illegal characters. withRawQueryString is made available both in a 'strict' and a 'relaxed' variation. Fixes akka#3002 (cherry picked from commit e284816)
release 10.1 backport of akka#3003 This makes sure 'strict' parsing of the Uri query string only allows characters that are actually allowed here by the RFC. It does not change the fact that Uri's rawQueryString is the percent-encoded representation of the query string, since this information is needed to parse it into a key-value structure. When parsing the Uri in 'relaxed' mode or constructing programmatically, we do accept characters that are not allowed, but percent-encode any would-be invalid characters. API's that can be used to programmatically add or modify the query string are adapted to not accept invalid percent-encoded values (e.g. %x2) and convert illegal characters. withRawQueryString is made available both in a 'strict' and a 'relaxed' variation. Fixes akka#3002 (cherry picked from commit e284816)
This makes sure 'strict' parsing of the Uri query string only allows characters that are actually allowed here by the RFC.
It does not change the fact that Uri's
rawQueryStringis the percent-encoded representation of the query string, since this information is needed to parse it into a key-value structure.When parsing the Uri in 'relaxed' mode or constructing programmatically, we do accept characters that are not allowed, but percent-encode any would-be invalid characters.
API's that can be used to programmatically add or modify the query string are adapted to not accept invalid percent-encoded values (e.g.
%x2) and convert illegal characters.withRawQueryStringis made available both in a 'strict' and a 'relaxed' variation.References #3002