bazi/gsb4j

Hexadecimal values support with \x escape

Closed this issue · 1 comments

// Assert.assertEquals( "http://%01%80.com/", hashPrefix.canonicalize( "http://\\x01\\x80.com/" ) );

Please suggest why did you comment this line? Yes, Java doesn't support '\x' escape symbol for hexadecimal values, but you still can replace all '\x' occurrences with '%' symbol manually and then you will be able to unescape every hexadecimal value prefixed with ''%".

The other problem here is that you will probably face
java.lang.IllegalArgumentException: java.text.ParseException: A prohibited code point was found in the input
from java.net.IDN because of "�" uncoded symbol. This symbol is considered as "Prohibited"

Please take a look at line number 448 here:
http://cr.openjdk.java.net/~malenkov/8022746.8.0/jdk/src/share/classes/sun/net/idn/StringPrep.java-.html

Thanks!

bazi commented

Thanks @Vadimka29 for pointing out this issue. That line was commented out from the beginning because I could not find reasons why it was failing back then :)

After reading your post, I realized how simple the issue was and actually conversion was already done in the code here. So after careful analysis I found that converting of '\x' to '%' was incorrectly performed before percent encoding here. Moving conversion down below solved the issue and that test is passing now!

Good catch! Thanks again.