Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#49347 closed defect (bug) (fixed)

redirect_canonical() removing trailing punctuation from any query string arg ending in p

Reported by: daveslaughter's profile daveslaughter Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 5.4 Priority: normal
Severity: normal Version: 5.3.2
Component: Canonical Keywords:
Focuses: Cc:


To reproduce add any query string with arg name ending p|page_id|cat|tag, and punctuation at the end of the value, e.g. ""

Actual behaviour is to redirect to "".

Expected behaviour is to not redirect.

The problem is in the redirect_canonical function, specifically the regex to "Remove trailing spaces and end punctuation from certain terminating query string args.", which is


The other regexes just after this code limit the query string args by making sure the complete arg name is checked, so the correct regex would be:


Attachments (1)

redirect_canonical.diff (798 bytes) - added by daveslaughter 4 years ago.

Download all attachments as: .zip

Change History (4)

#1 @SergeyBiryukov
4 years ago

  • Component changed from General to Canonical
  • Milestone changed from Awaiting Review to 5.4
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

Hi there, welcome to WordPress Trac! Thanks for the report and the patch.

Introduced in [41991].

#2 @SergeyBiryukov
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 47169:

Canonical: When removing trailing punctuation from query string arguments, match the whole query var name.

Props daveslaughter.
Fixes #49347.

#3 @daveslaughter
4 years ago

Thanks for sorting so quickly. This is my first bug report, and I must say I'm impressed with the speed and efficiency of the response.

Note: See TracTickets for help on using tickets.