WordPress.org

Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#1972 closed defect (bug) (wontfix)

Dots (.) in post slug are removed

Reported by: dto Owned by:
Milestone: Priority: low
Severity: trivial Version: 2.0.1
Component: General Keywords: post slug bg|has-patch bg|commit
Focuses: Cc:
PR Number:

Description

If the post slug contains any dots (.), they are removed mercilessly. However, dots should be allowed in slugs; for example, CNN.com uses them: http://www.cnn.com/2005/WORLD/asiapcf/11/27/china.water/

I'm pretty sure changing line 298 of /wp-includes/functions-formatting.php from

$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);

to

$title = preg_replace('/[^%a-z0-9 ._-]/', '', $title);

will do the trick.

Change History (9)

#1 @davidhouse
14 years ago

  • Keywords bg|has-patch added

#2 @davidhouse
14 years ago

  • Keywords bg|commit added

Don't see why not.

#3 @dto
14 years ago

  • Milestone set to 2.1
  • Version changed from 1.5.2 to 2.0.1

#4 @ryan
14 years ago

Changes to the sanitizer will break links made with previous versions of the sanitizer. We'd have to jump through some hoops to maintain backwards compat.

#5 @markjaquith
14 years ago

Changes to the sanitizer that make it LESS restrictive shouldn't break links.

If I have a post slug of 'this-slug' ... after this change, it would still be 'this-slug'

For posts with existing slugs, on update, the existing post slug is passed through the sanitizer... not the post title.

So if on January 1st, 2006, I posted an entry with the title "Stop. It's Hammer time." ... the post slug would be 'stop-its-hammer-time' and after the update it would stay the same, even though there are periods in the title. Periods would only go through for new posts.

At least, that's how I'm reading the code. changes that make the sanitizer MORE restrictive would obviously be bad and WOULD change existing slugs.

#6 @markjaquith
14 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

I tested this with a plugin, and it didn't cause any problems on my setup. But discussing with masquerade, davidhouse, and BigJibby, we couldn't agree on handling of things like ellipses, trailing ellipses, spaces next to dots, etc. I'm starting to think that although this might make some people happy, it'll just end up frustrating other people.

Plus, this is completely doable in a plugin. Here is the plugin that I used for testing:

http://txfx.net/files/wordpress/periods-in-titles.phps

The cleanup it does is the following:

  • ".-." converts to "."
  • ".-" converts to "."
  • "-." converts to "."
  • a single period at the end of the slug is removed (but note that 2 or more periods are left alone, so you can do "about-wordpress.com...")

Some examples:

  • "My Post Title." => "my-post-title"
  • "wordpress.com..." => "wordpress.com"'
  • "My . Post . Title" => "my.post.title"
  • "Post... Title..." => "post...title..."

I'm closing the ticket because:

  • It seems to be a minority who wants this change
  • Everyone will be affected, and some people won't like it
  • It can easily be done in a plugin

Please re-open if you have a compelling argument for inclusion into core, though!

#7 @dto
14 years ago

If people don't like this, that's fine. For me, it's just a matter of adding a '.' every time I upgrade. (The plugin is sort of ugly because I have to check whether the sanitize_title_with_dashes function changed during upgrades. But thanks.)

#8 @davidhouse
14 years ago

Well, no, you don't have to keep making the change: Mark's plugin does exactly what you want.

#9 @Nazgul
13 years ago

  • Milestone 2.1 deleted
Note: See TracTickets for help on using tickets.