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

Remove double/multiple forward slashes from the request path #88

Open
dav-pascual opened this issue Feb 10, 2023 · 3 comments · May be fixed by #99
Open

Remove double/multiple forward slashes from the request path #88

dav-pascual opened this issue Feb 10, 2023 · 3 comments · May be fixed by #99

Comments

@dav-pascual
Copy link
Collaborator

When using the gateway in directory listing mode, if you have a double slash in the path, the request won't find the folder or files.

I suggest removing extra slashes from the path using a rewrite, a map in the config or from JavaScript.

Example:
https://example.com/pathFoo//file.txt would become https://example.com/pathFoo/file.txt
https://example.com/pathFoo//subpathFoo/// would become https://example.com/pathFoo/subpathFoo/

@dekobon
Copy link
Collaborator

dekobon commented Feb 10, 2023

In principle, I like this idea. How would you propose to deal with the unlikely edge case that someone names their object something silly like: /file.txt

@dav-pascual
Copy link
Collaborator Author

In principle, I like this idea. How would you propose to deal with the unlikely edge case that someone names their object something silly like: /file.txt

AFAIK it's illegal that files or folders have slashes in their name both in AWS and Linux.

See (in AWS console):
image

Nevertheless, I have managed to create a folder with slashes in its name using aws-cli:
image

But I would consider it erractic behaviour. If you wanted to contemplate this extreme edge case, we could have a config ENVVAR to disable the removal of slashes.

@dekobon
Copy link
Collaborator

dekobon commented Feb 23, 2023

Hi @dav-pascual , I would very much welcome a PR that fixes this issue with a rewrite rule.

dav-pascual added a commit to dav-pascual/nginx-s3-gateway that referenced this issue Mar 5, 2023
dav-pascual added a commit to dav-pascual/nginx-s3-gateway that referenced this issue Mar 6, 2023
dav-pascual added a commit to dav-pascual/nginx-s3-gateway that referenced this issue Mar 6, 2023
dav-pascual added a commit to dav-pascual/nginx-s3-gateway that referenced this issue Mar 6, 2023
dav-pascual added a commit to dav-pascual/nginx-s3-gateway that referenced this issue Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants