Skip to content

Some inappropriate characters are included in auto-generated permalinks #12907

Open

Description

@greatislander

Describe the bug

In WordPress 5.0.1, creating a post or page with colons or exclamation marks in the title produces a permalink that takes the expected post/page slug form (lowercase alphanumeric with hyphens instead of spaces) but includes these special characters. Once the post/page is published the characters are stripped from the permalink.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new post or page.
  2. Enter a title with colons or exclamation marks.
  3. Save draft.
  4. Inspect the permalink.

Expected behavior

The permalink should contain only alphanumeric characters and hyphens, even before publishing the post/page.

Screenshots

The bug visible in the page title:

Screen shot of the page title and permalink.

The bug visible in the document inspector:

Screen shot of the permalink the document inspector.

Desktop:

  • OS: macOS Mojave 10.14.2
  • Safari 12.0.2

Additional context

  • I'm using the WordPress 5.0.1 bundled version of Gutenberg.
  • Other characters may be included as well, but I ran into the issue with these two (colon and exclamation mark) and haven't explored further.

Activity

  1. added
    [Feature] Permalink
    on Dec 15, 2018
  2. swissspidy commented on Dec 15, 2018

    @swissspidy
    Member
  3. greatislander commented on Dec 15, 2018

    @greatislander
    ContributorAuthor

    @swissspidy would it be more appropriate to submit a PR to this repo or a patch to core? Might have a chance to look at this.

  4. swissspidy commented on Dec 28, 2018

    @swissspidy
    Member

    It depends a bit on where the issue is. I'd probably start with a PR here and if there are some fixes necessary on the core side, create a patch on https://core.trac.wordpress.org/ticket/45478 as well.

  5. apermo commented on Jan 16, 2019

    @apermo
    Contributor

    Same problem here, including that umlaute are displayed wrong as long as the post is a draft.

    So ä becomes a, instead of ae, as it should. Once its saved, everything is ok.

  6. Dominic-t3ch commented on Mar 15, 2019

    @Dominic-t3ch

    I searched for this issue in WordPress with Gutenberg. Found some another tickets about this problem. Is there any news about this issue ? Still there with WordPress 5.1.1.

    Thanks

  7. added
    [Status] In Progress
    on Mar 19, 2020
  8. khoipro commented on Nov 23, 2021

    @khoipro
    Contributor

    Could we reopen this ticket? Our Vietnamese language still has an issue with that slug. @swissspidy @earnjam @ocean90

    Track my ticket https://core.trac.wordpress.org/ticket/54492

    Thanks, @SergeyBiryukov for referring here.

  9. removed their assignment
    on Jan 7, 2022
  10. IIM-Arvid commented on Feb 23, 2022

    @IIM-Arvid

    Hi,

    thanks for reopening the ticket. There are still problems mit other languages when saving the post as a draft. As stated in #16695 by @uok german "Umlauts" are not treaded properly (tested in 5.9.1).
    When creating a new post and entering a title like "Am nächsten Tag" and saving the post as a draft, the JS function mentioned above ( cleanForSlug() ) creates the slug "am-nachsten-tag" which is wrong. It has to be "am-naechsten-tag".

    If you save the post with other post-stati like "publish" or "future" the right slug is being created.
    The problem is that our editorial team is working with drafts to share the posts with other team members etc. They also use the generated slug / permalink for other purposes. For example: They copy the permalink and enter it in a browser push service. At the point the browser push is send out to thousands of users, the permalink has changed already because the post-status was now changed to "publish" and therefore the right slug was generated. Now all the users that click on the push message will see a 404 error page because the url was not found. And there are other cases in which this behavior causes problems.

    Since sanitize_title() is working like a charm on the PHP side, i have created this "light" workaround in our own plugin until the core JS function does handle this as well:

    add_filter( 'wp_insert_post_data', array( $this, 'sanitizeDraftPermalink' ) );

    public function sanitizeDraftPermalink( array $postData ) : array
    {
    if ( $postData['post_status'] === 'draft' && empty( $postData['post_name'] ) ) {
    $postData['post_name'] = sanitize_title( $postData['post_title'] );
    }
    return $postData;
    }

    Of course the JS side is not affected by this. So if you save the post as a draft, the wrong slug is still being created and shown. But if you reload the post now, the right slug is shown. At least that helps a little bit.

    Maybe there is a way to adopt the behavior from sanitize_title() on the JS side.

    Thank you very much

  11. removed
    [Status] In Progress
    on Mar 18, 2022
  12. 9 remaining items

  13. tyxla commented on Nov 3, 2022

    @tyxla
    Member

    Just curious, I assume you're able to handle those in your library?

    Yes.

    Looks like the version on GitHub is not the same as the one on npm

    Oops, seems like we forgot to tag the release here and only did it in npm. Just published it on GitHub as well: https://github.com/tyxla/remove-accents/releases/tag/v0.4.3. Thanks, @swissspidy!

  14. tyxla commented on Nov 22, 2022

    @tyxla
    Member

    @khoipro could I ask you to send me a thorough list of all the accented characters?

    My initial research shows that there are a bunch of different combinations of diacritics in every single character and I want to make sure I'm not missing any. Thanks in advance!

  15. khoipro commented on Feb 17, 2023

    @khoipro
    Contributor

    @tyxla @SergeyBiryukov I bump this ticket again.

    Here is the example of how to sanitize Vietnamese characters slug by another guy, but it works: https://gist.github.com/khoatran/8afeccd7a44c52ad39cfee00a093ec31

    Another case as old plugin:

    https://github.com/wp-plugins/vietnamese-slug/blob/master/vietnamese_slug.php

  16. tyxla commented on Feb 20, 2023

    @tyxla
    Member

    @khoipro - thanks, I'm happy to work on a new version of remove-accents that includes all those strings. Stay tuned.

  17. added
    [Status] In Progress
    on Aug 8, 2023
  18. tyxla commented on Aug 8, 2023

    @tyxla
    Member

    Vietnamese support was added in the latest version of remove-accents and I'm bumping its version and adding a test in #53420. From what I understand once we land it, we can close this issue.

    @khoipro let me know if that works well for you.

  19. tyxla commented on Aug 10, 2023

    @tyxla
    Member

    After shipping #53420 I've closed this one, but if there's any additional character needing support, feel free to reopen or open a new issue and I'd be happy to take care of it!

  20. apermo commented on Mar 5, 2026

    @apermo
    Contributor

    Reopening the German umlaut issue, as this is still present and has a real data-integrity impact that wasn't fully described before.

    The core problem

    German umlauts require locale-specific digraph replacements, not simple diacritic removal:

    • ä → ae, ö → oe, ü → ue, ß → ss (correct, German/de_DE)
    • ä → a, ö → o, ü → u, ß → s (what cleanForSlug() currently produces)

    This is not a missing character mapping — it's a locale rule that only applies in German context. PHP's remove_accents() handles this via a de_DE locale check. The remove-accents npm package has no locale concept, so it always produces the non-German result.

    Steps to reproduce — cosmetic only (wrong preview)

    1. Set site language to de_DE (Settings → General → Site Language)
    2. Open the block editor, create a new post
    3. Enter title: Künstler überraschen Hörer
    4. Observe slug preview in the editor: kunstler-uberraschen-horer
    5. Publish without touching the slug
    6. Observe actual saved permalink: kuenstler-ueberraschen-hoerer ✓

    Server-side sanitize_title() generates the correct slug on publish because post_name is empty and PHP uses the site locale. So far, cosmetic only.

    Steps to reproduce — real data integrity bug

    1. Same setup, steps 1–4 above
    2. Observe that the editor shows kunstler-uberraschen-horer
    3. Click the slug to edit it — normal SEO workflow, user wants to shorten it
    4. The slug input is pre-filled with the wrong JS-generated value
    5. User types a shortened version based on what they see: kunstler-horer (missing the ue replacements)
    6. Publish
    7. Saved permalink: kunstler-horer — permanently wrong

    Once a user manually edits the slug, WordPress locks it — subsequent title changes no longer update it. The wrong transliteration is now permanent and the post has the wrong URL for its entire lifetime.

    Why this affects editorial teams specifically

    Our editors routinely customize slugs for SEO. The workflow is: write title → check auto-generated slug → shorten/optimize → publish. Step 2 of that workflow now shows them a wrong value, and any edit they make at step 3 bakes that wrong value in.

    ###Possible fix

    The cleanest solution would be for the editor to use the generated_slug field already returned by the REST API (computed server-side via sanitize_title()) to populate/correct the slug preview, rather than relying solely on client-side cleanForSlug(). The server already does the right thing — the editor just isn't using its output.

    Alternatively, locale-specific rules could be added to cleanForSlug() / remove-accents, using the site locale available from the REST API settings endpoint.

    Disclaimer: Research and documentation supported by Claude Code and results verified by myself.

    Edit: @tyxla I can't reopen it, missing the rights to it, would you be so kind to reopen it?

  21. added 2 commits that reference this issue on Mar 6, 2026
    f3bc29a
    68f596f
  22. tyxla commented on Mar 9, 2026

    @tyxla
    Member

    This is an interesting problem, thanks @apermo, reopening!

  23. reopened this on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

[Feature] Permalink[Status] In Progress[Type] Bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions