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

storage/url: Allow usage of adjacent slashes #459

Merged
merged 8 commits into from
Jul 22, 2022

Conversation

boraberke
Copy link
Contributor

@boraberke boraberke commented Jul 5, 2022

This PR allows url with adjacent slashes to be handled correctly.

  • Disabled Automatic URI cleaning (search in this link for more information) as it do not allow adjacent slashes.
  • Changed path.Join method to strings.Join when joined remote urls as path.Join also cleans paths which removes additional slashes.
  • Kept local urls to be joined with path.Join.
  • Added test cases for copy command for following cases:
    • Remote to local
    • Local to remote
    • Remote to remote
  • Removed redundant leading slashes in the keys of s3 objects in ls_test.go and sync_test.go files.

Users should be careful while handling slashes in objectnames. Before this PR,s5cmd cp /file.txt s3://bucket/ would output

cp /file.txt s3://bucket/file.txt

But now it will result in double slashes as follows:

cp /file.txt s3://bucket//file.txt

Fixes: #352
Fixes: #449

This commit allows url with adjacent slashes to be handled correctly.

- Disabled RestProtocolURICleaning (link) as it do not allow adjacent slashes.
- Changed path.Join method to strings.Join when joined remote urls. path.Join also cleans paths which removes additional slashes.
- Kept local urls to be joined with path.Join.
- Added test cases for copy;
    - Remote to local
    - Local to remote
    - Remote to remote
- Removed redundant trailing slashes in the keys of s3 objects in ls_test.go and sync_test.go files.

Fixes: peak#352 ,peak#449
Replaced strings.Cut method as it is undefined before go version 1.18.x
@boraberke boraberke requested a review from a team as a code owner July 5, 2022 15:49
@boraberke boraberke requested review from igungor and seruman and removed request for a team July 5, 2022 15:49
e2e/cp_test.go Outdated Show resolved Hide resolved
e2e/cp_test.go Outdated Show resolved Hide resolved
storage/url/url.go Outdated Show resolved Hide resolved
storage/url/url.go Outdated Show resolved Hide resolved
storage/url/url.go Outdated Show resolved Hide resolved
storage/url/url.go Outdated Show resolved Hide resolved
storage/url/url.go Outdated Show resolved Hide resolved
storage/url/url.go Show resolved Hide resolved
storage/url/url.go Show resolved Hide resolved
storage/s3.go Outdated Show resolved Hide resolved
Copy link
Member

@igungor igungor left a comment

Choose a reason for hiding this comment

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

@boraberke could you update the changelog file to reflect this change please? I'm not sure if this is a bugfix or an improvement :)

@seruman
Copy link
Member

seruman commented Jul 21, 2022

@boraberke could you update the changelog file to reflect this change please? I'm not sure if this is a bugfix or an improvement :)

Might even breaking for users who rely on URI cleaning 🙃 .

@boraberke
Copy link
Contributor Author

@boraberke could you update the changelog file to reflect this change please? I'm not sure if this is a bugfix or an improvement :)

Added three more entries to CHANGELOG.MD further explaining the details of this PR :)

CHANGELOG.md Outdated Show resolved Hide resolved
@igungor igungor merged commit 6b87fb4 into peak:master Jul 22, 2022
@boraberke boraberke deleted the bug-fix-unknown-url-format branch July 27, 2022 10:35
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.

storage: unknown url format s5cmd drops leading slashes in keys
3 participants