WPPack Sanitize Characters
Sanitize invisible and control characters (zero-width spaces, BOM, bidi controls, C0/C1 controls, soft hyphens) out of posts, ACF fields and search terms, plus a WP-CLI command to clean existing data.
by WPPack · github.com/wppack-io/sanitize-characters-plugin · website
★ 0stars
317composer installs
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/wppack-io/sanitize-characters-plugin/archive/refs/heads/1.x.zipAlso on Packagist as wppack/sanitize-characters-plugin:
composer require wppack/sanitize-characters-pluginFrom the readme
WPPack Sanitize Characters
日本語版 README
Sanitizes invisible and control characters out of content on its way into
WordPress and out of search terms on their way into a query. No settings
screen, no options in the database.
The problem
Word processors and note-taking tools (Google Docs, Notion, …) inject
zero-width characters into text as soft line-break hints; PDFs and terminals
leak control characters and odd separators. Pasted into WordPress they
survive invisibly inside titles, body text and search boxes. Search then
fails on strings that look identical on screen: a title containing
Broadway (with a hidden U+200B) never matches a typed Broadway, and a
pasted search term with a trailing zero-width space matches nothing — in the
admin search, in ACF relationship fields and in the front-end ?s= search
alike. As a bonus, MySQL's utf8mb4 collations treat these characters as
ignorable, which makes the corruption invisible to SQL too.
What gets sanitized
| Characters | Treatment |
|---|---|
| C0 controls except TAB/LF/CR, DEL, C1 controls (U+0000–U+001F, U+007F–U+009F) | removed |
| U+00AD SOFT HYPHEN | removed |
| Zero-width: U+200B, U+2060, U+FEFF (BOM) | removed |
| Bidirectio