#8642 closed defect (bug) (fixed)
Canonical redirect of feed URLs with suffixes is wrong
Reported by: | jhodgdon | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 2.7.1 | Priority: | normal |
Severity: | normal | Version: | 2.7 |
Component: | Canonical | Keywords: | redirect has-patch |
Focuses: | Cc: |
Description
As of [10215] and the 2.7 release, if for some reason I have a URL like
(myblogurl)/feed/(suffix)
then the redirect in wp-includes/canonical.php function redirect_canonical() redirects this to
(myblogurl)/feed/(suffix)/feed/
and that URL 404s.
The reason this happens is that the redirect_canonical() function, when it is dealing with feed-related URLs:
- strips off /feed/ only from the end of the URL
- checks is_feed() (which returns true if /feed/ is in the URL anywhere)
- if is_feed() is true, it assumes /feed/ has been completely stripped from the URL (which it hasn't if the /feed/ is not at the end), and adds /feed/ to the end of the URL.
The patch I am about to add to this report additionally strips /feed/ off the middle of the URL, which at least makes the redirect work for me -- then it redirects to
(myblogurl)/(suffix)/feed/
which works just fine.
By the way, there are some other places in the WP code where this assumption has been made, that certain things are always coming in at the end of URLs and not in the middle -- I have run into this before in previous WP versions and gotten around it with annoying shenanigans in my plugin that adds suffixes to URLs (among other functionality). Some of these issues are elsewhere in that same canonical_redirect() function, and some are in the rewrite logic (especially the parts of both having to do with paging). So if you feel ambitious, you might want to search these out and fix them. If not, I'd appreciate it if you could at least put this patch into the 2.7.1 release.
Attachments (2)
Change History (8)
#1
@
16 years ago
- Component changed from General to Canonical
- Owner changed from anonymous to markjaquith
#2
@
16 years ago
8642.002.diff does the same, but within the existing regex. Does that fix it, Jennifer?
#3
@
16 years ago
I didn't know you could put a $ as a conditional inside a regex like that, cool! But I guess it is just a special matching character, after all. Duh.
I'll test this out shortly.
Patch to fix this bug by stripping /feed/ out of the middle of URLs in canonical redirect code