Closed asfimport closed 12 years ago
Takayuki Kaneko (migrated from Bugzilla): Created attachment patch.txt: patch forJOrphanUtils
Sebb (migrated from Bugzilla): Under what circumstances does java.net.URLDecoder not work correctly?
Can you provide some examples that we can add to a test case?
Takayuki Kaneko (migrated from Bugzilla): This JSP is tested on Tomcat5.0.30 and WindowsXP(Japanese).
Created attachment test.jsp: Encoding Test JSP Example
This JSP tests decoding methods.
If you push post button, string in textbox will be decoded by org.apache.catalina.util.RequestUtil.
If you push get button, string in textbox will be decoded by java.util.URLDecoder.
Some characters aren't decoded correctly. It is caused by mismatch between IE encoding and URLDecoder decoding.
You can copy&paste following Japanese Characters and push button!
getQueryString: <%=query%>
Decoded String: <%=str%>
````Takayuki Kaneko (migrated from Bugzilla): Hi Sebb,
Thank you for replying.
I attached new JSP Example for encode/decode tests. I expect you will be able to understand circumstances on java.net.URLDecoder. Please check it out.
Regards,
Tetsuya Takatsuru (migrated from Bugzilla): org.apache.commons.codec.net.URLCodec#encode/decode is better than java.net.URLEncoder/URLDecoder.
java.net.URLDecoder cannot decode correctly in this case:
===example String s = "登録";
String commons_encoded = new URLCodec("MS932").encode(s); System.out.println("Encoded by commons-codec: " + commons_encoded); // outputs: Encoded by commons-codec: %93o%98%5E // some CJK multi-byte encodings use ASCII area at second byte. // IE and Firefox (and some other browsers) encodes like as this.
String java_encoded = URLEncoder.encode(s, "MS932"); System.out.println("Encoded by java.net.URLEncoder: " + java_encoded); // outputs: Encoded by java.net.URLEncoder: %93%6F%98%5E
System.out.println(URLDecoder.decode(java_encoded, "MS932")); //OK System.out.println(URLDecoder.decode(commons_encoded, "MS932")); //NG System.out.println(new URLCodec("MS932").decode(java_encoded)); //OK System.out.println(new URLCodec("MS932").decode(commons_encoded)); //OK ===end example
Tetsuya Takatsuru (migrated from Bugzilla): Created attachment JMeter_URLCodec.patch: using Commons URLCodec instead of java.net.URLDecoder/Encoder
Tetsuya Takatsuru (migrated from Bugzilla): Created attachment Screenshot.png: screenshot when running my example
@pmouawad (migrated from Bugzilla): This bug has been marked as a duplicate of https://github.com/apache/jmeter/issues/2118
Takayuki Kaneko (Bug 38115): java.net.URLDecoder sometimes can't handle decoding correctry. It depends on behaviour of IE's encoding.
But Tomcat can handle decoding correctry. So I made a patch of decoding in reference to Tomcat decoding (org.apache.catalina.util.RequestUtil class).
Regards,
Severity: normal OS: other
Duplicated by:
Blocks: