Make WordPress Core

Opened 8 years ago

Last modified 5 years ago

#35794 new defect (bug)

redirect_canonical doesn't strip off custom feed endings

Reported by: huyby's profile huyby Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.9
Component: Canonical Keywords: needs-patch
Focuses: Cc:


The pattern used for matching URL's with feed endings (e.g. /feed/atom/) isn't matching any custom defined feeds. For example, if you add 'json' as a new type of feed, the redirect_canonical function adds up the feed ending to the current request URL.

This is caused by fixed regular expressions used to match such feed URL's. These regular expressions should be generated using the $wp_rewrite->feeds variable:

 $feedssubpattern = implode('|', array_map(function($val) { return preg_quote($val, '#'); }, $wp_rewrite->feeds));
 $pattern = '#/(comments/?)?(' . $feedssubpattern . ')(/+)?$#';

Attachments (2)

patch.txt (1.7 KB) - added by huyby 8 years ago.
patch.2.txt (1.5 KB) - added by huyby 8 years ago.
Patch, no color codes this time :)

Download all attachments as: .zip

Change History (4)

8 years ago


#1 @johnbillion
8 years ago

  • Keywords needs-patch added

Thanks for the report and the patch, @huyby!

It looks like your command line is piped through something that adds colour coding, and the markings for this are present in your patch file. Are you able to regenerate your patch without the colour coding in place please?

8 years ago

Patch, no color codes this time :)

#2 @huyby
8 years ago

Done! I also noticed I left a debug line uncommented, it was commented before, so fixed that and removed from the patch.



Note: See TracTickets for help on using tickets.