jetty.project
jetty.project copied to clipboard
HttpURI.parseQuery rejects `[` and `]` characters in path section
Jetty version(s) 12.0.13
Jetty Environment Any
Java version/vendor (use: java -version)
Any
OS type/version Any
Description As reported in
- https://github.com/jetty/jetty.project/pull/12012#issuecomment-2343430545
This change causes unencoded [ and ] to be rejected too (400 Illegal Path Character). Not sure if that is intended?
How to reproduce?
> GET /[] HTTP/1.1 > Host: api:8080 > User-Agent: curl/7.64.0 > Accept: */* > < HTTP/1.1 400 Bad Request < Server: Jetty(12.0.12) < Cache-Control: must-revalidate,no-cache,no-store < Content-Type: text/html;charset=iso-8859-1 < Content-Length: 437 < Connection: close < <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/> <title>Error 400 Illegal Path Character</title> </head> <body> <h2>HTTP ERROR 400 Illegal Path Character</h2> <table> <tr><th>URI:</th><td>/badURI</td></tr> <tr><th>STATUS:</th><td>400</td></tr> <tr><th>MESSAGE:</th><td>Illegal Path Character</td></tr>
The [ and ] are considered reserved characters in the gen-delims ABNF in the URI spec.
https://datatracker.ietf.org/doc/html/rfc3986#section-2.2
Those two characters are reserved for IPv6 or IPvLiteral authority sections on the URI.
Seems like the change from parsing the whole URI to just parsing the pathQuery is tripping up the gen-delims vs sub-delims nuance of the path parsing.
For the parsing of URI path, the ANBF doesn't mention that the gen-delims characters as part of pchar, is that the flaw?
See: https://datatracker.ietf.org/doc/html/rfc3986#section-3.3