Make WordPress Core

Opened 11 years ago

Last modified 7 years ago

#35794 new defect (bug)

redirect_canonical doesn't strip off custom feed endings

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

Description

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 11 years ago.
patch
patch.2.txt (1.5 KB ) - added by huyby 11 years ago.
Patch, no color codes this time :)

Download all attachments as: .zip

Change History (4)

@huyby
11 years ago

patch

#1 @johnbillion
11 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?

@huyby
11 years ago

Patch, no color codes this time :)

#2 @huyby
11 years ago

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

cheers

s.

Note: See TracTickets for help on using tickets.