netty: QueryStringDecoder does not decode correctly path part with '+' (plus) sign in it

Expected behavior

‘+’ is a valid char for path part of URI, it should not be replaced by space.

Actual behavior

‘+’ is replaced with space.

Steps to reproduce

Minimal yet complete reproducer code (or URL to code)

public void testURIPathDecoding() throws URISyntaxException {
    String path = "/a/path/with/a+in.it";
    URI uri = new URI("http", "www.bbbb.com", path, null);
    System.out.println(path.equals(uri.getPath()));
    System.out.println(path.equals(uri.getRawPath()));
    QueryStringDecoder dec = new QueryStringDecoder(uri.getRawPath());
    System.out.println(dec.path());
    System.out.println(path.equals(dec.path()));
    System.out.println(path.equals(dec.uri()));
  }

true
true
/a/path/with/a in.it
false
true

Netty version

4.1.11

JVM version (e.g. java -version)

OS version (e.g. uname -a)

Any

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Found one more problem: a charset does not work as intended… Code

System.out.println(new URI("случайный%20праздник").getPath());
System.out.println(QueryStringDecoder.decodeComponent("случайный%20праздник"));
System.out.println(QueryStringDecoder.decodeComponent("случайный праздник"));

return

случайный праздник
A;CG09=K9 ?@074=8:
случайный праздник

I’ll try to fix this too.