Don't Double URL Query Args in Canonical Redirect
|Reported by:||filosofo||Owned by:||MarkJaquith|
Currently, when using "default" permalinks and requesting something that triggers canonical redirect, the query portion of the request URL can double up the same request arguments, which leads to redirect_canonical()'s returning falsely different URLs.
In other words, suppose you have a custom post type of custom_post_thing with an object that has a slug a-custom-post-thingy-title and an ID of 123.
If you request /?p=123 redirect_canonical() figures out that its correct, canonical URL is actually
However, when redirect_canonical() is called again at line 362, it appends the same query value to the fetched URL, like so:
The result is that
differ as strings even though they're the same in actual meaning, and the redirect fails and a 404 results.
(I have seen this happen in other redirect situations--it's not limited to custom post types.)
The patch parses the redirect URL's query value and uses add_query_arg() to add it, rather than the current naive string concatenation. The result is that arguments do not get doubled, and the redirect succeeds.