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

Marlformed query strings can cause infinate redirects #541

Open
joehoyle opened this issue Feb 28, 2022 · 0 comments
Open

Marlformed query strings can cause infinate redirects #541

joehoyle opened this issue Feb 28, 2022 · 0 comments
Labels
bug Existing functionality isn't behaving as expected

Comments

@joehoyle
Copy link
Member

joehoyle commented Feb 28, 2022

This is quite similar to #302 from what I can see.

Steps to reproduce:

  1. Set your front-page to a page in WP settings
  2. Make sure batcache is enabled
  3. Request https://yoursite.com/?=123
  4. Observe redirect_canonical should redirect to https://yoursite.com/
  5. Try to request https://yoursite.com/
  6. Observe an infinite redirect to https://yoursite.com/

When the query string is "malformed", specifically in this case, it's an empty key in ?=123 (no key, value of 123). In these situations $_GET is [], but $_SERVER['QUERY_STRING'] is =123. And, parse_url will be ["query"]=> string(4) "=123"

As you can maybe imagine, this causes issues when the assumption is the query / URL can be re-built from $_GET. One place that makes this assumption is Batcache. Effectively the cache will be stored as if there were no query params (see https://github.com/humanmade/batcache/blob/master/advanced-cache.php#L555, parse_str('=123', $result ) === []).

As redirect_canonical will do a 301 redirect, that redirect will get stored in Batcache against the homepage with no url params cache key. Therefore, the homepage will infinite redirect.

@joehoyle joehoyle added the bug Existing functionality isn't behaving as expected label Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing functionality isn't behaving as expected
Projects
None yet
Development

No branches or pull requests

1 participant