Skip to content

Fix violation of UTF-8 invariant in str creation#2455

Merged
mzagozen merged 1 commit into
mainfrom
fix-utf-8
Sep 23, 2025
Merged

Fix violation of UTF-8 invariant in str creation#2455
mzagozen merged 1 commit into
mainfrom
fix-utf-8

Conversation

@mzagozen

Copy link
Copy Markdown
Collaborator

Acton strings must always contain valid UTF-8. Functions in str.c rely on this, so we must ensure that B_str is always valid and raise an exception if it is not valid.

to$str() and to_str_noc() had incorrect ASCII detection that checked bytes after incrementing the pointer, skipping the first byte. This caused strings starting with non-ASCII bytes (e.g., \xe8\x03) to be misclassified as ASCII, bypassing UTF-8 validation entirely.

Acton strings must always contain valid UTF-8. Functions in str.c rely
on this, so we must ensure that B_str is always valid and raise an
exception if it is not valid.

to$str() and to_str_noc() had incorrect ASCII detection that checked
bytes after incrementing the pointer, skipping the first byte. This
caused strings starting with non-ASCII bytes (e.g., \xe8\x03) to be
misclassified as ASCII, bypassing UTF-8 validation entirely.
@mzagozen mzagozen enabled auto-merge September 23, 2025 16:11
@mzagozen mzagozen merged commit eea2578 into main Sep 23, 2025
35 checks passed
@mzagozen mzagozen deleted the fix-utf-8 branch September 23, 2025 16:25
@mzagozen mzagozen mentioned this pull request Sep 24, 2025
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.

1 participant