Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special characters in permalink not being properly converted #18177

Closed
bartczyz opened this issue Oct 30, 2019 · 2 comments

Comments

@bartczyz
Copy link

@bartczyz bartczyz commented Oct 30, 2019

Describe the bug
In Danish there are some extra letters - Ø Å and I've noticed that they are not being properly converted, so:

  • "Ø" should be converted to "OE"
  • "Å" should be converted to "AA"

Initially I thought that this might be an issue with Core, but after doing some tests the characters are converted properly when using Classic Editor:

danish_special_characters_classic_editor

Since it's not an issue with Core it has to be an issue with Gutenberg. 🤔

image

In Gutenberg post-permalink component contains a method called onSavePermalink(), that method is using cleanForSlug() helper function that is responsible for performing basic cleanup of a string for use as a post slug.

From what I noticed that function is using lodash.deburr() that deburrs string by converting Latin-1 Supplement and Latin Extended-A letters to basic Latin letters and removing combining diacritical marks, which is causing the whole issue.

To reproduce
Steps to reproduce the behavior:

  1. Go to 'Add New Post'
  2. Put 'Ø Å' in the title and save the post
  3. Click on the saved title to see the slug

Expected behavior
To behave in the same manner as Core.

Additional context

  • I was testing on WordPress 5.2.4 and WordPress 5.3 using Gutenberg 6.7.0.
@getdave

This comment has been minimized.

Copy link
Contributor

@getdave getdave commented Nov 6, 2019

Looks like a good candidate for a PR. Here is the offending function

export function cleanForSlug( string ) {

@swissspidy

This comment has been minimized.

Copy link
Member

@swissspidy swissspidy commented Nov 6, 2019

This is a longstanding and known issue. The main discussing is being tracked in #12907, but it also has been reported in #16695 before. I am therefore closing it as a duplicate.

That doesn't mean it's not a valid report or anything, it just helps us keep a better eye on things.

As for the cleanForSlug function, it already states in the docs that it is somewhat similar to sanitize_title. The only real way would be to replicate the function as-is (some duplicated logic across PHP and JS), or use the REST API (inefficient)

@swissspidy swissspidy closed this Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.