Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove use of from_utf8_unchecked in macos process handling #1257

Conversation

vthib
Copy link
Contributor

@vthib vthib commented Apr 18, 2024

Those unsafe functions have been observed to not respect their safety constraints, as some values retrieved from the macos API are not guaranteed to be UTF-8.

This is fixed by replacing those calls with from_utf8_lossy, which will replace those values with a replacement character to ensure the generated String is valid.

This solution is not ideal, but the master branch contains the better fix: an OsString is returned to let the caller decide how to handle the value.

Changing those calls remove the need of unsafe blocks, so those were removed at the same time.

Fixes #1256

Those unsafe functions have been observed to not respect their safety
constraints, as some values retrieved from the macos API are not
guaranteed to be UTF-8.

This is fixed by replacing those calls with `from_utf8_lossy`, which
will replace those values with a replacement character to ensure the
generated String is valid.

This solution is not ideal, but the master branch contains the better
fix: an OsString is returned to let the caller decide how to handle the
value.

Changing those calls remove the need of unsafe blocks, so those were
removed at the same time.
@GuillaumeGomez GuillaumeGomez merged commit 438eef0 into GuillaumeGomez:0.30 Apr 18, 2024
67 checks passed
@vthib vthib deleted the 1256-fix-macos-process-utf8-issues branch April 18, 2024 20:49
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.

None yet

2 participants