Skip to content

duplicate query parameters #205

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

Closed
katrinaaquino1 opened this issue Jan 29, 2024 · 4 comments
Closed

duplicate query parameters #205

katrinaaquino1 opened this issue Jan 29, 2024 · 4 comments
Assignees

Comments

@katrinaaquino1
Copy link

Describe the bug
An extra set of query parameters is added to the URL

To Reproduce
Steps to reproduce the behavior:

  1. Start container with APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=true, ALLOW_DIRECTORY_LIST=false, PROVIDE_INDEX_PAGE=true, and an index.html file at /test/index.html
  2. Run container and navigate to /test?a=asd
  3. index.html loads but URL is updated to /test/?a=asd?a=asd

Expected behavior
The index.html page loads and the URL remains /test?a=asd or updates to /test/?a=asd

Your environment
Using the most recent version of the master branch - 0cdacac
Running the container using the included Dockerfile.oss file on localhost
Using AWS S3 as a backend

Additional context
I noticed the duplication only happens when navigating to /test?a=asd, but not /test/?a=asd or /test/index.html?a=asd

@4141done
Copy link
Collaborator

Thank you for your report @katrinaaquino1 I will investigate this one this week

@4141done
Copy link
Collaborator

4141done commented Feb 6, 2024

Hi @katrinaaquino1 I discovered the source of the bug and have a PR up to fix it here #209

Would you be able to give it a test with your use case before I merge it? There are not any images pushed at the moment but if you have the ability to build and test it against your use case it would be appreciated.

@katrinaaquino1
Copy link
Author

@4141done This fix works for my use case. Thanks!

4141done added a commit that referenced this issue Feb 7, 2024
…IRECTORY would cause duplication of the query string (#209)

# What
As reported here #205 when 
* `APPEND_SLASH_FOR_POSSIBLE_DIRECTORY=true`
* `ALLOW_DIRECTORY_LIST=false`
* `PROVIDE_INDEX_PAGE=true`
Are set, requests containing query strings without a trailing slash were being duplicated (`foo?a=b` were becoming `foo?a=b?a=b`).

## Cause
The `rewrite` directive will automatically append the query string unless a final trailing `?` is supplied. This was causing the duplication

## Fix
Added an explanatory comment and a trailing `?` to the rewrite rule to prevent automatic appending of the query string as we already do it in the argument to the rewrite rule.

I chose to do this rather than depending on the default behavior of `rewrite` since the rule as it is expressed is more explicit.  The trailing `?` is mysterious and so a comment was included to clarify.
@4141done
Copy link
Collaborator

4141done commented Feb 7, 2024

@katrinaaquino1 Thank you again for reporting this bug. The fix has been merged and new versions of the docker image with the fix are available on github packages and docker hub. Sorry for any inconvenience it may have caused 🙏

GH Packages: https://github.com/nginxinc/nginx-s3-gateway/pkgs/container/nginx-s3-gateway%2Fnginx-oss-s3-gateway/176123712?tag=latest-20240207

Dockerhub: https://hub.docker.com/layers/nginxinc/nginx-s3-gateway/latest-20240207/images/sha256-1cefcddd07a1154dfbc2e0ea3b603c1a824a0f197f4d060aa99c6224e680ac3f?context=explore

Please feel free to reopen this issue of the problem persists.

@4141done 4141done closed this as completed Feb 7, 2024
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

No branches or pull requests

2 participants