#49347 closed defect (bug) (fixed)
redirect_canonical() removing trailing punctuation from any query string arg ending in p
| Reported by: | daveslaughter | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.4 |
| Component: | Canonical | Version: | 5.3.2 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
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. "www.example.com/?comp=East+(North)"
Actual behaviour is to redirect to "www.example.com/?comp=East+(North".
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
#(((p|page_id|cat|tag)=[^&]*?)($punctuation_pattern)+$#
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:
#((^|&)(p|page_id|cat|tag)=[^&]*?)($punctuation_pattern)+$#
Attachments (1)
Change History (4)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Hi there, welcome to WordPress Trac! Thanks for the report and the patch.
Introduced in [41991].