Ticket #569 (closed defect: fixed)

Opened 4 years ago

Last modified 2 years ago

Percent sign (%) in title leads to unusable permalinks

Reported by: MC_incubus Assigned to: 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 (0.8 kB) - added by MC_incubus on 05/21/05 06:31:05.
template-functions-links.diff (0.6 kB) - added by stilgar on 05/22/06 22:05:13.
569.diff (502 bytes) - added by majelbstoat on 08/22/06 12:10:22.
urlencode pathinfo before we try to match it in parse_request()
569b.diff (479 bytes) - added by majelbstoat on 08/26/06 02:32:21.
Only encode the % sign.

Change History

12/19/04 09:28:05 changed by MC_incubus

  • Patch set to No.

12/19/04 09:56:35 changed by Kitten

Reminder sent to MC_incubus

I'll look into this.

12/19/04 09:56:48 changed by Kitten

  • owner changed from anonymous to Kitten.
  • status changed from new to assigned.

12/19/04 10:16:15 changed by Kitten

  • 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.

05/21/05 06:31:05 changed by MC_incubus

  • attachment functions-formatting.diff added.

05/22/06 22:03:50 changed by stilgar

  • status changed from closed to reopened.
  • version set to 2.0.2.
  • resolution 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.

05/22/06 22:05:13 changed by stilgar

  • attachment template-functions-links.diff added.

07/05/06 17:52:35 changed by filosofo

  • keywords set to bg|has-patch.

07/08/06 07:14:48 changed by majelbstoat

  • keywords changed from bg|has-patch to bg|has-patch bg|2nd-opinion.

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.

08/22/06 12:09:28 changed by majelbstoat

  • keywords changed from bg|has-patch bg|2nd-opinion to bg|has-patch.
  • 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.

08/22/06 12:10:22 changed by majelbstoat

  • attachment 569.diff added.

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

08/26/06 02:30:36 changed by majelbstoat

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.

08/26/06 02:32:21 changed by majelbstoat

  • attachment 569b.diff added.

Only encode the % sign.

09/19/06 03:05:10 changed by ryan

  • status changed from reopened to closed.
  • resolution set to fixed.

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

09/25/06 02:50:13 changed by ryan

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

09/25/06 04:22:46 changed by foolswisdom

  • milestone changed from 2.1 to 2.0.5.

11/30/06 19:41:51 changed by

  • milestone deleted.

Milestone 2.0.5 deleted