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

Wrong request-body decoding for content-type "application/x-www-form-urlencoded" #1212

Closed
AlexaWeisse opened this issue Dec 25, 2017 · 6 comments

Comments

@AlexaWeisse
Copy link
Contributor

Hi,
there is request with content-type "application/x-www-form-urlencoded; charset=utf-8" and cyrillic symbols in body. After update to play-1.5.0 from play-1.2.7.2 controller params contain invalid character sequences instead cyrillic words. This is due to an error in org.apache.common.codec.net.URLCodec#decode(java.lang.String, java.lang.String) (used in play/data/parsing/UrlEncodedParser.java:132).
For example:

final String str = "Привет";
System.out.println("java.net.URLDecoder: " + URLDecoder.decode(str, "UTF-8")); // in play 1.2.7.2
System.out.println("org.apache.commons.codec.net.URLCodec: " + new URLCodec().decode(str, "UTF-8")); // in play 1.5.0

Output:

java.net.URLDecoder: Привет
org.apache.commons.codec.net.URLCodec: ??????

This error lies in the incorrect receipt of bytes: string.getBytes(Charsets.US_ASCII);
So this decision works only for standard ascii-symbols.
Please fix the error.

@asolntsev
Copy link
Contributor

@AlinaDidenko Can you prepare a pull request?

@AlexaWeisse
Copy link
Contributor Author

@asolntsev Yes, we will try to fix it

AlexaWeisse added a commit to AlexaWeisse/play1 that referenced this issue Jan 11, 2018
@GordeevArt
Copy link

Why no review? Why not in the 1.5.1 version?

@asolntsev
Copy link
Contributor

@GordeevArt is there a pull request that we could review?

@GordeevArt
Copy link

@asolntsev #1213

xael-fry added a commit that referenced this issue Aug 23, 2018
[#1212] Fix non-Latin characters decode in UrlEncodedParser
@xael-fry xael-fry added this to the 1.5.2 milestone Aug 27, 2018
@xael-fry
Copy link
Member

Merge #1213
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants