Skip to content

Fixes #2619: properly handle plus signs when resolving paths - #2623

Merged
vietj merged 6 commits into
masterfrom
feature/urldecode-no-plus
Sep 25, 2018
Merged

vietj merged 6 commits into
masterfrom
feature/urldecode-no-plus

Conversation

@pmlopes

@pmlopes pmlopes commented Sep 13, 2018 •

Copy link
Copy Markdown
Contributor

Fixes #2619

And the new utility is exposed on the public package io.vertx.net so it can be reused from vertx-web where it originally was implemented.

Signed-off-by: Paulo Lopes <paulo@mlopes.net>
@pmlopes pmlopes added this to the 3.5.4 milestone Sep 13, 2018
@pmlopes pmlopes added the bug label Sep 13, 2018
@pmlopes
pmlopes requested review from tsegismont and vietj and removed request for vietj September 13, 2018 09:12
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
@vietj
vietj force-pushed the feature/urldecode-no-plus branch from 737770a to 630f0f3 Compare September 14, 2018 07:30
@vietj

vietj commented Sep 14, 2018

Copy link
Copy Markdown
Member
  • I'm wondering why there are so few tests for code that does not seem trivial ?
  • can you move this in net.impl package I would like avoiding to supporting it in API as it does not seem required

@pmlopes

pmlopes commented Sep 14, 2018

Copy link
Copy Markdown
Contributor Author

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.

@vietj

vietj commented Sep 14, 2018

Copy link
Copy Markdown
Member

I think vertx web can use it from an impl package without a problem.

please port all tests to avoid breakage.

pmlopes and others added 3 commits September 17, 2018 19:59
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
@pmlopes
pmlopes force-pushed the feature/urldecode-no-plus branch from 23dea48 to 938ea24 Compare September 19, 2018 08:16
Comment thread src/main/java/io/vertx/core/net/impl/URIDecoder.java Outdated
final char c = s.charAt(i);
if (c == '%' || (plus && c == '+')) {
modified = true;
break;

@vietj vietj Sep 24, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return s, the modified flag is unnecessary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh right :-)

if (!modified) {
return s;
}
final byte[] buf = s.getBytes();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use an encoding when getting the bytes otherwise it will use the default platform charset

@vietj vietj Sep 24, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually since we only write in buff, we should create a byte[], using getBytes() will result in unnecessary CPU usage.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Comment thread src/main/java/io/vertx/core/net/impl/URIDecoder.java
Signed-off-by: Paulo Lopes <paulo@mlopes.net>
@vietj vietj modified the milestones: 3.5.4, 3.6.0 Sep 25, 2018
@vietj
vietj merged commit 095195a into master Sep 25, 2018
vietj pushed a commit that referenced this pull request Sep 25, 2018
* 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>
@vietj
vietj deleted the feature/urldecode-no-plus branch May 26, 2020 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants