WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 38 hours ago

#20383 accepted defect (bug)

Strip trailing punctuation with canonical URLs

Reported by: nacin Owned by: joostdevalk
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Canonical Keywords: has-patch dev-feedback
Focuses: Cc:

Description

A follow-up to #7537 where we removed %20 and " " from the end of URLs, we should try to remove all sorts of punctuation from the end of a URL, both URL-encoded and decoded.

Example bad URLs we should surely be able to resolve:

http://ma.tt/2012/03/productivity-per-square-inch/%7B

http://ma.tt/2012/03/productivity-per-square-inch/)

http://ma.tt/2012/03/productivity-per-square-inch/,

http://ma.tt/2012/03/productivity-per-square-inch/!

More difficult when there is no trailing slash in the permalink structure (or the link requested, regardless of permalink structure), but if is_404() is taken into account, it should be doable to trail various pieces of punctuation and see if we can get things to resolve.

Attachments (1)

20383.patch (659 bytes) - added by joostdevalk 2 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 @n3k43 years ago

  • Cc hellokane@… added

@joostdevalk2 years ago

comment:2 @joostdevalk2 years ago

  • Keywords has-patch reporter-feedback added
  • Owner set to joostdevalk
  • Status changed from new to accepted

I added the suggested ones and a couple more into the same rewrite in which we fixed the trailing space. WordPress doesn't allow for these characters in the URL so I think it's safe to assume that if they're in there, at the end of the URL, it's a mistake.

Please do tell me if you disagree, if so I could move this to redirect_guess_404_permalink without issue of course.

comment:3 @chriscct738 hours ago

  • Keywords dev-feedback added; reporter-feedback removed
Note: See TracTickets for help on using tickets.