[wp-trac] [WordPress Trac] #15774: Don't Double URL Query Args in Canonical Redirect
WordPress Trac
wp-trac at lists.automattic.com
Sat Dec 11 09:42:14 UTC 2010
#15774: Don't Double URL Query Args in Canonical Redirect
--------------------------+-------------------------------------------------
Reporter: filosofo | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: 3.1
Component: Canonical | Version: 3.1
Severity: normal | Keywords: has-patch
--------------------------+-------------------------------------------------
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
{{{
/?custom_post_thing=a-custom-post-thingy-title
}}}
However, when `redirect_canonical()` is called again at line 362, it
appends the same query value to the fetched URL, like so:
{{{
/?custom_post_thing=a-custom-post-thingy-title&custom_post_thing=a-custom-
post-thingy-title
}}}
The result is that
{{{
/?custom_post_thing=a-custom-post-thingy-title&custom_post_thing=a-custom-
post-thingy-title
}}}
and
{{{
/?custom_post_thing=a-custom-post-thingy-title
}}}
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.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15774>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list