Ticket #569 (closed defect (bug): fixed)

Opened 7 years ago

Last modified 5 years ago

Percent sign (%) in title leads to unusable permalinks

Reported by: MC_incubus Owned by: Kitten
Priority: normal Milestone:
Component: General Version: 2.1
Severity: major Keywords: bg|has-patch
Cc:

Description

The percent sign (%) in entry titles is incorrectly put into the post slug, breaking the permalink for that entry.

Attachments

functions-formatting.diff Download (848 bytes) - added by MC_incubus 7 years ago.
template-functions-links.diff Download (586 bytes) - added by stilgar 6 years ago.
569.diff Download (502 bytes) - added by majelbstoat 5 years ago.
urlencode pathinfo before we try to match it in parse_request()
569b.diff Download (479 bytes) - added by majelbstoat 5 years ago.
Only encode the % sign.

Change History

  • Patch set to No

Reminder sent to MC_incubus

I'll look into this.

  • Owner changed from anonymous to Kitten
  • Status changed from new to assigned
  • Status changed from assigned to closed
  • Resolution changed from 10 to 20

This patch fixes this problem by removing '%' signs from the url completely. Tested, and will clean up old posts that have '%' signs in the title if they're opened for editing and re-saved.

  • Status changed from closed to reopened
  • Version set to 2.0.2
  • Resolution fixed deleted

This is still the case in WordPress 2.0.2.

The problem isn't that the permalink contains '%', this can be allowed, but that the get_permalink function in template-functions-links.php doesn't urlencode $post->post_name, so an invalid url is generated.

  • Keywords bg|has-patch added
  • Keywords bg|2nd-opinion added

Not sure this is useful as it stands. For me, all that this patch seems to do is to make Firefox's status bar less readable:

/path/to/permalink/これは何ですか。/

which is a readable Japanese permalink in the status bar becomes:

/path/to/permalink/2006/07/05/%e3%81%93%e3%82%8c%e3%81%af%e4%bd%95%e3%81%a7%e3%81%99%e3%81%8b%ef%bd%a1/

which isn't so useful. In IE there is no difference, as with or without this patch the URL is seemingly automatically encoded by the browser. Even without the patch applied, Firefox automatically encodes the link correctly. I haven't tried on other browsers, but I imagine that most (all?) modern ones will behave nicely. Besides which doesn't sanitize_title_with_dashes() already sort out the post-slug as it is created?

In any case, this patch doesn't fix the problem as the above permalink still gives a 404 for me on latest trunk even after it is applied. It looks like the permalink containing octets isn't matching the regular expression rules correctly, though I can't see why.

Jamie.

  • Keywords bg|2nd-opinion removed
  • Version changed from 2.0.2 to 2.1
  • Milestone set to 2.1

I believe I've found the problem. In parse_request() in classes.php, the path info is stripped from the end of the requested URI. However, the path is not URI encoded, so it fails to match in the str_replace. This patch urlencodes the path info (minus slashes) so it can be tested properly.

With the patch applied, all permalinks, including encoded ones, are followable.

urlencode pathinfo before we try to match it in parse_request()

On second thoughts, urlencoding everything in the path could break plugins that do rewrite rules checking. This new patch only encodes '%' to '%25', which still fixes the non-followable permalinks problem, without potentially causing problems elsewhere.

Only encode the % sign.

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

(In [4195]) Encode percent to avoid broken permalinks. Props majelbstoat. fixes #569

(In [4243]) Encode percent to avoid broken permalinks. Props majelbstoat. fixes #569

  • Milestone changed from 2.1 to 2.0.5
  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

Note: See TracTickets for help on using tickets.