Skip to content
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

HierarchicalUriComponents.encodeUriComponent() method can not encode Pchar [SPR-17621] #22153

Closed
spring-issuemaster opened this issue Dec 22, 2018 · 2 comments
Assignees

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Dec 22, 2018

sunbufu opened SPR-17621 and commented

Hi guy,

I have a question about HierarchicalUriComponents.encodeUriComponent() method. I think it should encode all special char in url query param, Actually, It can not encode many special char. For example + - ! $ ... in url query param. and my email is [sunyoubufu@qq.com|mailto:sunyoubufu@qq.com] . 


Affects: 5.0.6

Reference URL: https://github.com/spring-projects/spring-framework/blob/5.0.x/spring-web/src/main/java/org/springframework/web/util/HierarchicalUriComponents.java

Attachments:

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 23, 2018

Brian Clozel commented

Did you take a loot at the RFC that's referenced from the implementation here?

The RFC 3986 states that the following characters are allowed in a query string (see the appendix A in the ABNF):

query         = *( pchar / "/" / "?" )
pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
pct-encoded   = "%" HEXDIG HEXDIG
sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                 / "*" / "+" / "," / ";" / "="

This means that sub-delimiters are allowed in query strings and do not need to be percent encoded (that includes +, $).

Now I understand that some legal characters might still have a special meaning. We've applied some changes to be more consistent with the encoding of URLs (see #21399), and I think you're ultimately after what was addressed in #21577 (see the dedicated section in the reference documentation).

Thanks!

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 23, 2018

sunbufu commented

Got it. Thanks very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.