Fixes #2619: properly handle plus signs when resolving paths - #2623
Conversation
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
737770a to
630f0f3
Compare
|
|
The reason it's outside implementation is because I'd like to use it on Web where it originally came from. Avoiding 2 identical implementations. I can port the tests from Web too. |
|
I think vertx web can use it from an impl package without a problem. please port all tests to avoid breakage. |
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
23dea48 to
938ea24
Compare
| final char c = s.charAt(i); | ||
| if (c == '%' || (plus && c == '+')) { | ||
| modified = true; | ||
| break; |
There was a problem hiding this comment.
just return s, the modified flag is unnecessary
There was a problem hiding this comment.
the loop is inverted, if the flag is true means we're not on the happy path and we need to start deciding from the current i
| if (!modified) { | ||
| return s; | ||
| } | ||
| final byte[] buf = s.getBytes(); |
There was a problem hiding this comment.
Use an encoding when getting the bytes otherwise it will use the default platform charset
There was a problem hiding this comment.
Actually since we only write in buff, we should create a byte[], using getBytes() will result in unnecessary CPU usage.
There was a problem hiding this comment.
I reuse the generated byte[] from the i where we detected the first % char. So I could either create a new byte[] and loop over the string to copy bytes (and i need bytes not chars) or let this do some extra work by copying the bytes and waste the decoded bytes from i to the end...
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
* Fixes #2619: properly handle plus signs when resolving paths Signed-off-by: Paulo Lopes <paulo@mlopes.net> * Fixes #2619: properly handle plus signs when resolving paths Signed-off-by: Paulo Lopes <paulo@mlopes.net> * updates based on review Signed-off-by: Paulo Lopes <paulo@mlopes.net> * Delete URIDecoder.java Signed-off-by: Paulo Lopes <paulo@mlopes.net> * Updates based on the review Signed-off-by: Paulo Lopes <paulo@mlopes.net>
Fixes #2619
And the new utility is exposed on the public package
io.vertx.netso it can be reused fromvertx-webwhere it originally was implemented.