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-projects-issues opened this issue Dec 22, 2018 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply

Comments

@spring-projects-issues
Copy link
Collaborator

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-projects-issues
Copy link
Collaborator Author

spring-projects-issues 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-projects-issues
Copy link
Collaborator Author

sunbufu commented

Got it. Thanks very much.

@spring-projects-issues spring-projects-issues added type: bug A general bug status: declined A suggestion or change that we don't feel we should currently apply in: web Issues in web modules (web, webmvc, webflux, websocket) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues removed the type: bug A general bug label Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

2 participants