Merged
Conversation
I originally added special handling for WASI OS strings because I saw `std::os::wasi::ffi::OsStrExt` in the docs and assumed that meant WASI worked like Unix. It doesn't. The consensus is to only permit Unicode. `wasmtime` rejects invalid UTF-8: $ wasmtime target/wasm32-wasip2/debug/examples/echo.wasm $'\xff' Error: failed to convert "\xFF" to utf-8 Most platforms re-export Unix's `OsStrExt` and WASI happens to be one of the platforms for which docs are built. But in practice any string that passes between a WASI program and the OS must be Unicode. Invalid OS strings can only be created using the extension traits. Also, on the new `wasm32-wasip2` target `std::os::wasi::ffi::OsStrExt` is marked unstable, and so lexopt failed to build. So we no longer treat WASI specially in the library. It's now just another fallback target that sometimes has to use `OsStr::to_string_lossy`. In the tests however we can now use `wasm32-wasip1` to finally test how the fallback code reacts to invalid OS strings. This was never very exciting but it's nice to have it covered.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I originally added special handling for WASI OS strings because I saw
std::os::wasi::ffi::OsStrExtin the docs and assumed that meant WASI worked like Unix.It doesn't. The consensus is to only permit Unicode.
wasmtimerejects invalid UTF-8:Most platforms re-export Unix's
OsStrExtand WASI happens to be one of the platforms for which docs are built. But in practice any string that passes between a WASI program and the OS must be Unicode. Invalid OS strings can only be created using the extension traits.Also, on the new
wasm32-wasip2targetstd::os::wasi::ffi::OsStrExtis marked unstable, and so lexopt failed to build.So we no longer treat WASI specially in the library. It's now just another fallback target that sometimes has to use
OsStr::to_string_lossy.In the tests however we can now use
wasm32-wasip1to finally test how the fallback code reacts to invalid OS strings. This was never very exciting but it's nice to have it covered.