Skip to content

yes: accept invalid-Unicode arguments on Windows (#12236)#2

Open
crutkas wants to merge 1 commit into
mainfrom
fix/yes-invalid-unicode-12236
Open

yes: accept invalid-Unicode arguments on Windows (#12236)#2
crutkas wants to merge 1 commit into
mainfrom
fix/yes-invalid-unicode-12236

Conversation

@crutkas

@crutkas crutkas commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Fixes uutils#12236.

yes rejected non-UTF-8 arguments on Windows: a preflight str::from_utf8 check (#[cfg(not(any(unix, target_os = "wasi")))]) returned exit code 1 for any argument containing, e.g., an unpaired UTF-16 surrogate. The output path only writes raw bytes, so the check was unnecessary — removing it makes Windows stream the argument bytes exactly like Unix already does (and resolves the in-code todo: accept invalid utf8).

Test: adds test_non_unicode_windows, the Windows analogue of the existing Unix-only test_non_utf8, asserting an unpaired surrogate (0xD800) is streamed as its WTF-8 bytes ED A0 80 instead of erroring.

Verified on Windows: cargo test -p coreutils --no-default-features --features yes --test tests -- test_yes → 8 passed.

`yes` ran a preflight `str::from_utf8` check on non-Unix platforms and
rejected any argument that was not valid UTF-8, so on Windows an argument
containing an unpaired UTF-16 surrogate failed with exit code 1. The
output path only ever writes raw bytes (`write_all`), so the validation
was unnecessary. Remove it so Windows streams the argument bytes just like
Unix already does, resolving the existing `todo: accept invalid utf8`.

Add a Windows regression test mirroring the Unix `test_non_utf8`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

yes: support invalid unicode on Windows

1 participant