Skip to content

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

Open
@dav-pascual

Description

@dav-pascual
Contributor

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/

Activity

dekobon

dekobon commented on Feb 10, 2023

@dekobon
Collaborator

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

dav-pascual commented on Feb 15, 2023

@dav-pascual
ContributorAuthor

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

dekobon commented on Feb 23, 2023

@dekobon
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @dekobon@dav-pascual

      Issue actions

        Remove double/multiple forward slashes from the request path · Issue #88 · nginx/nginx-s3-gateway