Opened 3 years ago
Closed 3 years ago
#5711 closed defect (bug) (fixed)
Anchor id not sanitized
Reported by: | sebastienserre | Owned by: | dd32 |
---|---|---|---|
Milestone: | Priority: | normal | |
Component: | Handbooks | Keywords: | needs-patch |
Cc: |
Description
Hello,
We have a problem in the French documentation team with the id
in the doc title.
As you may know, in French we have specials characters which need to be sanitized before being used in an URL.
Example:
the page https://fr.wordpress.org/support/article/faq-troubleshooting/#indésirablesspams will produce the really ugly https://fr.wordpress.org/support/article/faq-troubleshooting/#ind%c3%a9sirablesspams
It should be great if the id
used to create the HTML anchor should be sanitized thanks to sanitize_title()
.
Change History (11)
#2
in reply to:
↑ 1
@
3 years ago
Replying to sebastienserre:
sanitize_title_with_dashes
is doing what it's intended to, the problem is that it's expected to have accents removed/replaced prior to calling it.
The appropriate code would be sanitize_title_with_dashes( remove_accents( $title ) )
or potentially just sanitize_title( $title )
which does the same thing, but with a more filtered list of slug creation filters.
#3
@
3 years ago
- Owner set to dd32
- Resolution set to fixed
- Status changed from new to closed
In 10920:
#6
@
3 years ago
I wonder if sanitize_title() shouldn't be used as we can find as @papicx in the french doc: https://fr.wordpress.org/support/article/introduction-to-blogging/#les-slugs-d%e2%80%99articles
I think using sanitize_title() should solve this. What do you think @dd32 ?
#7
@
3 years ago
and this one with non-breaking spaces and double quotes entering and leaving
https://fr.wordpress.org/support/article/introduction-to-blogging/#qu%e2%80%99est-ce-qu%e2%80%99un-%c2%abblog%c2%bb
#8
@
3 years ago
@audrasjb suggests us on French Slack: https://developer.wordpress.org/reference/functions/sanitize_file_name/ which cover non-breaking-spaces and double-quotes
#9
@
3 years ago
remove_accents
(or sanitize_title
) doesn't handle curly apostrophes, so maybe it would be better to use sanitize_file_name
(see this Core ticket https://core.trac.wordpress.org/ticket/50231).
By checking the code, https://github.com/WordPress/wordpress.org/blob/1700e58c5b77172dc118670903f7636d592a0a46/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php#L95 the id seems to be sanitized, so maybe it's a problem with https://developer.wordpress.org/reference/functions/sanitize_title_with_dashes/ ?