Skip to content

Fix. Patch. utf8_decode() polyfill turned non-ASCII characters into NUL bytes - #55

Merged
alexandergull merged 1 commit into
CleanTalk:devfrom
samipuro:fix/utf8-decode-polyfill
Oct 29, 2026
Merged

alexandergull merged 1 commit into
CleanTalk:devfrom
samipuro:fix/utf8-decode-polyfill

Conversation

@samipuro

Copy link
Copy Markdown

The utf8_decode() polyfill in lib/cleantalk-php-patch.php combines the bits of multi-byte characters with & instead of |, so every non-ASCII character becomes 0 (a NUL byte). For example, café becomes caf\0 instead of caf\xE9.

This changes the six & operators between the shifted parts to |. The fixed polyfill now returns byte-for-byte the same output as the native utf8_decode() for ASCII, Latin-1 (café, Ünïcödé), characters outside Latin-1 (€, 日本, which become ?) and 4-byte emoji.

@alexandergull
alexandergull changed the base branch from master to dev October 29, 2026 07:29
@alexandergull
alexandergull merged commit e9d672d into CleanTalk:dev Oct 29, 2026
1 check passed
@alexandergull

Copy link
Copy Markdown
Member

Merged into dev branch. Also, we plan to fix the same cases in other repos.

Thank you very much.

@alexandergull

Copy link
Copy Markdown
Member

The next stable release will include this pull request. The estimated release timeline is 14 days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants