[wp-trac] [WordPress Trac] #49347: redirect_canonical() removing trailing punctuation from any query string arg ending in p
WordPress Trac
noreply at wordpress.org
Sun Feb 2 21:39:10 UTC 2020
#49347: redirect_canonical() removing trailing punctuation from any query string
arg ending in p
---------------------------+-----------------------------
Reporter: daveslaughter | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 5.3.2
Severity: normal | Keywords:
Focuses: |
---------------------------+-----------------------------
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)+$#
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49347>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list