#1972 closed defect (bug) (wontfix)
Dots (.) in post slug are removed
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | low | Milestone: | |
| Component: | General | Version: | 2.0.1 |
| Severity: | trivial | Keywords: | post slug bg|has-patch bg|commit |
| Cc: |
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)
comment:1
davidhouse
— 8 years ago
- Keywords bg|has-patch added
comment:2
davidhouse
— 7 years ago
- Keywords bg|commit added
comment:4
ryan
— 7 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.
comment:5
markjaquith
— 7 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.
comment:6
markjaquith
— 7 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!
comment:7
dto
— 7 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.)
comment:8
davidhouse
— 7 years ago
Well, no, you don't have to keep making the change: Mark's plugin does exactly what you want.
Don't see why not.