WordPress.org

Make WordPress Core

Opened 16 years ago

Closed 14 years ago

Last modified 14 years ago

#569 closed defect (bug) (fixed)

Percent sign (%) in title leads to unusable permalinks

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

Description

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

Attachments (4)

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

Download all attachments as: .zip

Change History (17)

#1 @MC_incubus
16 years ago

  • Patch set to No

#2 @Kitten
16 years ago

Reminder sent to MC_incubus

I'll look into this.

#3 @Kitten
16 years ago

  • Owner changed from anonymous to Kitten
  • Status changed from new to assigned

#4 @Kitten
16 years ago

  • Resolution changed from 10 to 20
  • Status changed from assigned to closed

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.

#5 @stilgar
15 years ago

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

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.

#6 @filosofo
15 years ago

  • Keywords bg|has-patch added

#7 @majelbstoat
15 years ago

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

#8 @majelbstoat
15 years ago

  • Keywords bg|2nd-opinion removed
  • Milestone set to 2.1
  • Version changed from 2.0.2 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.

@majelbstoat
15 years ago

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

#9 @majelbstoat
15 years ago

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.

@majelbstoat
15 years ago

Only encode the % sign.

#10 @ryan
14 years ago

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

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

#11 @ryan
14 years ago

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

#12 @foolswisdom
14 years ago

  • Milestone changed from 2.1 to 2.0.5

#13 @(none)
14 years ago

  • Milestone 2.0.5 deleted

Milestone 2.0.5 deleted

Note: See TracTickets for help on using tickets.