Repository navigation
Don't cache requests with a malformed Host header - #1116
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wpsc_is_get_query()checked for a query string by parsing the request URI together with the Host header, so a malformed Host header could make it miss one, and the page could be cached under the wrong URL.The fix
wp-cache-base.phpvalidates the Host header with a newwpsc_is_valid_http_host(): a hostname or a bracketed IPv6 literal, with an optional port from 1 to 65535 written without leading zeros. Anything else turns caching off for that request: nothing is served from the cache or written to it, and the page renders normally.wpsc_is_get_query()now decides fromREQUEST_URIalone, through a newwpsc_uri_has_query().wpsc_remove_tracking_params_from_uri()returns the URI unchanged when it can't parse it, rather than an empty string.Behaviour changes
Testing
make test: 160 tests, green. The new tests are inWpscIsValidHttpHostTest,WpscUriHasQueryTestandWpscRemoveTrackingParamsTest.make test-integration: 53 tests, green.make lint: clean.Release Notes