-
Notifications
You must be signed in to change notification settings - Fork 335
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
Unsafe audit #560
Unsafe audit #560
Conversation
Thanks for doing this audit! It looks like the new Also, |
f332e0c
to
592f776
Compare
@SimonSapin Thanks for the review.
Good catch, I was thinking only about allocations. I've rolled this back, but added some small comments/tweaks that I think improve readability. Let me know what you think.
This makes sense. For now, I've rolled back the de-duplication and added a note so if those functions are modified in the future they can be changed in both places. It seems the ideal case would be for this functionality to live in the standard library. I'm thinking the function signature of impl String {
fn from_utf8_lossy(bytes: T) -> Cow<str>
where T: LossyConvertibleBytes;
} Where |
Regarding the standard library’s |
Is there any further work you'd like to see here before merging? |
There seem to be no outstanding concerns on this PR. Is anything still blocking the merge? |
☔ The latest upstream changes (presumably #607) made this pull request unmergeable. Please resolve the merge conflicts. |
be2660f
to
fa1d0ff
Compare
fa1d0ff
to
8dfa679
Compare
I've rebased and updated this based on the latest changes. Let me know if this needs anything else. |
☔ The latest upstream changes (presumably 3b587ea) made this pull request unmergeable. Please resolve the merge conflicts. |
I've applied some minor formatting tweaks to your commit and pushed it as 3b587ea. Thanks for all the work! |
Hello,
I just did a quick unsafe audit, directed here from rust-secure-code/safety-dance#51.
I was able to remove the unsafe block from
decode_utf8_lossy
. Also, I removed the duplicate definition ofdecode_utf8_lossy
by allowingsrc/form_urlencoded.rs
to import it frompercent_encoding/lib.rs
rather thansrc/query_encoding.rs
.All other unsafe blocks look appropriate to me, as they ensure we don't waste CPU cycles checking the validity of bytes that we already have confirmed in some way as safe to convert to UTF-8, but I added comments to justify why they are safe.