Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support URLencoding during normalization #396

Merged
merged 5 commits into from
Jan 9, 2024

Conversation

raboof
Copy link
Member

@raboof raboof commented May 16, 2023

Earlier, the path would be URL-decoded after normalization. This meant some opportunities for normalization would be missed when dots or slashes were URL-encoded.

One way to solve this would be to change the ordering of operations, but that seems risky as it would change the meaning of some of the abstractions. Because of that I opted for a more conservative approach, where normalization will take into account URL-encoded characters, but otherwise leave the input string intact.

@raboof raboof force-pushed the urldecoded-normalization branch 3 times, most recently from af17cb7 to 6c12c74 Compare May 16, 2023 16:47
@raboof raboof force-pushed the urldecoded-normalization branch 4 times, most recently from 6f73d37 to e421bfd Compare May 27, 2023 19:25
private int cursor = 0;
private int lastSeparator;
private int end;
PathNormalizer(StringBuilder path) {
Copy link
Member

Choose a reason for hiding this comment

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

Use final where you can.

Copy link
Member

@garydgregory garydgregory left a comment

Choose a reason for hiding this comment

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

Hi @raboof
A few nits 😉

boolean reading = true;
while (reading) {
reading = readNonSeparator();
}
Copy link
Member

Choose a reason for hiding this comment

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

Simpler to say `while (readNonSeparator()); ?

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm, it seems PMD won't let me

}
return false;
}
private boolean readDot() {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Add a blank line b/w methods.

@raboof raboof force-pushed the urldecoded-normalization branch from e421bfd to 8f33bb3 Compare January 8, 2024 14:39
Earlier, the path would be URL-decoded after normalization.
This meant some opportunities for normalization would be missed
when dots or slashes were URL-encoded.

One way to solve this would be to change the ordering of operations,
but that seems risky as it would change the meaning of some of the
abstractions. Because of that I opted for a more conservative
approach, where normalization will take into account URL-encoded
characters, but otherwise leave the input string intact.
@raboof raboof force-pushed the urldecoded-normalization branch from 8f33bb3 to f1611bf Compare January 8, 2024 14:47
@garydgregory
Copy link
Member

garydgregory commented Jan 8, 2024

@raboof
Run mvn before you push to catch build errors. In this case, this PR breaks binary compatibility because it makes a previously public constructor private. I took the liberty of fixing to see if we can get to a green build 😉

@raboof
Copy link
Member Author

raboof commented Jan 8, 2024

Ah, rebase mistake... thx for the fix, not sure what's going on with DefaultFileSystemManagerTest.testResolveFileNameType, will look into that tomorrow.

Might need some more reviewing to make sure this logic is correct
@raboof raboof marked this pull request as draft January 8, 2024 22:32
@raboof raboof force-pushed the urldecoded-normalization branch from 444ac4a to 31e0882 Compare January 8, 2024 22:44
@garydgregory
Copy link
Member

Error:  src/main/java/org/apache/commons/vfs2/provider/UriParser.java:[528,1] (whitespace) FileTabCharacter: File contains tab characters (this is the first instance).

Run mvn before you push to catch build errors 😉

@raboof raboof force-pushed the urldecoded-normalization branch from 31e0882 to ec42e65 Compare January 9, 2024 08:18
@raboof raboof force-pushed the urldecoded-normalization branch from 01b8934 to c95b48d Compare January 9, 2024 13:03
@raboof
Copy link
Member Author

raboof commented Jan 9, 2024

Run mvn before you push to catch build errors 😉

I know ;) - some of the tests are failing or very slow on my machine (even on the main branch), probably because I'm running in a sandbox, so I've been running individual targets - sorry about the noise ;) . Now getting 500's that are not our fault it looks like though, https://www.githubstatus.com/

Do you want me to squash the commits above?

@raboof raboof marked this pull request as ready for review January 9, 2024 13:20
@garydgregory
Copy link
Member

Don't worry about the noise 😉
WRT squashing, up to you, I normally squash before merging unless there's a good reason not to do so.

@garydgregory
Copy link
Member

Looks like we'll have to wait for GH to fix itself...

@garydgregory
Copy link
Member

Re-running builds now that GH is back up...

@garydgregory garydgregory merged commit cb45c94 into apache:master Jan 9, 2024
15 checks passed
garydgregory added a commit that referenced this pull request Jan 9, 2024
raboof added a commit to raboof/commons-vfs that referenced this pull request Jun 26, 2024
The reverts apache#396 and related
changes and implements the same in a simpler way by replacing the
encoded characters already in `fixSeparators`.

This approach has a slightly higher risk at breaking existing behaviour,
but a lower risk of remaining problems in this part of the codebase. All
testcases still succeed.

This PR is intended to replace apache#543 and apache#555

This reverts commit cb45c94.
This reverts commit 5399c76.
raboof added a commit to raboof/commons-vfs that referenced this pull request Jun 26, 2024
The reverts apache#396 and related
changes and implements the same in a simpler way by replacing the
encoded characters already in `fixSeparators`.

This approach has a slightly higher risk at breaking existing behaviour,
but a lower risk of remaining problems in this part of the codebase. All
testcases still succeed.

This PR is intended to replace apache#543 and apache#555. It includes the testcases
from apache#543, adapted to the behaviour before apache#396.

This reverts commit cb45c94.
This reverts commit 5399c76.

Co-Authored-By: Anthony Goubard <[email protected]>
@raboof raboof mentioned this pull request Jun 26, 2024
raboof added a commit to raboof/commons-vfs that referenced this pull request Jun 26, 2024
The reverts apache#396 and related
changes and implements the same in a simpler way by replacing the
encoded characters already in `fixSeparators`.

This approach has a slightly higher risk at breaking existing behaviour,
but a lower risk of remaining problems in this part of the codebase. All
testcases still succeed.

This PR is intended to replace apache#543 and apache#555. It includes the testcases
from apache#543, adapted to the behaviour before apache#396.

This reverts commit cb45c94.
This reverts commit 5399c76.

Co-Authored-By: Anthony Goubard <[email protected]>
raboof added a commit to raboof/commons-vfs that referenced this pull request Jul 25, 2024
The reverts apache#396 and related
changes and implements the same in a simpler way by replacing the
encoded characters already in `fixSeparators`.

This approach has a slightly higher risk at breaking existing behaviour,
but a lower risk of remaining problems in this part of the codebase. All
testcases still succeed.

This PR is intended to replace apache#543 and apache#555. It includes the testcases
from apache#543, adapted to the behaviour before apache#396.

This reverts commit cb45c94.
This reverts commit 5399c76.

Co-Authored-By: Anthony Goubard <[email protected]>
garydgregory pushed a commit that referenced this pull request Jul 27, 2024
* Simplify UriParser

The reverts #396 and related
changes and implements the same in a simpler way by replacing the
encoded characters already in `fixSeparators`.

This approach has a slightly higher risk at breaking existing behaviour,
but a lower risk of remaining problems in this part of the codebase. All
testcases still succeed.

This PR is intended to replace #543 and #555. It includes the testcases
from #543, adapted to the behaviour before #396.

This reverts commit cb45c94.
This reverts commit 5399c76.

Co-Authored-By: Anthony Goubard <[email protected]>

* Add benchmark for UriParser

---------

Co-authored-by: Anthony Goubard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants