You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 04b4e47
Browse filesBrowse the repository at this point in the historyBrowse files
refactor: extract the UTF-8 sequence decoder from utf8_unicode_inplace_ex
The two-, three- and four-byte branches repeated the same pattern: check
the byte count, check each continuation byte for binary 10, shift in six
bits. Move that into utf8_decode_sequence(), which derives the sequence
length from the lead byte and loops over the continuation bytes. The NUL
special case and the surrogate, range and overlong checks stay in the
caller, so the output is unchanged.
SonarCloud reported a cognitive complexity of 51 for the function on
PR owasp-modsecurity#3685 (accepted there); it is now 17, with 10 for the helper.
Verified output-identical to the previous version with a standalone
harness under ASan and UBSan: every input of 1 to 3 bytes, every 4-byte
input with a high lead byte and a third of the fourth-byte values, and
20 million random 4 to 15 byte inputs biased to high bytes and NUL:
758,263,296 cases, 0 mismatches. tests/tfn/utf8toUnicode.t passes 11/11.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tz1sULBvqAwnRreKh5eC9h
0 commit comments