hal4j / uritemplate

Java implementation of RFC 6570 (URI template)
Apache License 2.0
3 stars 0 forks source link

Non-ASCII chars are not pct-encoded #8

Closed C06A closed 11 months ago

C06A commented 1 year ago

According to RFC-6570 the only unencoded characters are from unreserved set and in case of Reserved and Fragment Expansions -- also from reserved set. I try to use Cyrillic chars in the values and they are not pct-encoded.

ivan-gammel commented 1 year ago

@C06A see linked pull request: I cannot reproduce the issue in unit tests. Could you please provide more details or better a test that would demonstrate the bug?

C06A commented 1 year ago

Here is the simple test:

    @Test
    public void simpleCyrilicTest() {
        String s = new URITemplate("{+cyrillic}")
                .expand( "cyrillic", "АБВГДЕйка")
                .toString();
        assertEquals("%D0%90%D0%91%D0%92%D0%93%D0%94%D0%95%D0%B9%D0%BA%D0%B0", s);
    }

which results in:

org.opentest4j.AssertionFailedError: 
Expected :%D0%90%D0%91%D0%92%D0%93%D0%94%D0%95%D0%B9%D0%BA%D0%B0
Actual   :АБВГДЕйка
<Click to see difference>
Screen Shot 2023-09-04 at 12 06 09 PM
ivan-gammel commented 11 months ago

Fixed in version 2.0.0