Skip to content

Fix readme to reflect the use of GitHub Actions #424

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

Closed
wants to merge 9 commits into from

Conversation

sbosnick
Copy link
Contributor

This updates the Build Status badge to reflect the move to GitHub Actions.

sbosnick added 9 commits May 2, 2020 12:09
Document the sound use of unsafe in HeaderValue::to_str().
The tests inlcude variation on the placement of unicode codepoints that
encode to multi-byte UTF-8 and an instance of a [u8] with invalid UTF-8
that is still a valid HeaderValue.
The new code uses Iterator::try_fold() instead of external iteration to
review the bytes in the HeaderValue and separate the printing of visible
ascii bytes printing other bytes (and special casing b'"').

This new implementation may behave slightly different for a HeaderValue
of length usize::MAX, but such a HeaderValue is likely to exhaust memory
before the Debug impl comes into play (which also makes it hard to test
this hypothetical edge case).
The comments describe the invariants that make the use of unsafe sound.
The simplification removes the need for one of the invariants that
described how the use of unsafe is sound.
HeaderValue::from_maybe_shared_unchecked() is currently an unsafe
function but it could be made a safe function without intoducing a
soundness hole because it does not do anything directly that depends on
`unsafe` and it isn't protecting any invariants of HeaderValue that are
relied upon later when using `unsafe`.

from_maybe_shared_unchecked() can accept bytes as a HeaderValue that are
invalid bytes for what is described in RFC 7230 (section 3.2) but all
such bytes would still be valid to convert directly to a str since they
are all valid single-byte UTF-8.
HeaderValue::from_maybe_shared_unchecked had been marked unsafe but this
was to indicate caller responsibility for api constraints and not caller
responsibility for avoiding undefined behaviour. This change removes the
use of unsafe for this purpose and instead uses a more explict doc
comment to draw the caller's attention to the restrictions (as well as
the continued use of the "_unchecked" suffix.

This is not a breaking change (despite affecting the public API) because
removing "unsafe" from a function still allows existing uses to compile.

This use of "unsafe" was not protecting an invariant on the internal
structre of HeaderValue that was relined on in unsafe blocks elsewhere
in the module to ensure the absence of undefined behaviour. All (other)
unsafe blocks in this module rely on local checking to ensure they avoid
undefined behaviour.
Some of the comments describing the invariants necessary to ensure the
sound use of "unsafe" refered to an older version of the reasoning that
had used 2 invariants. This change makes them refer to "the invariant"
instead of "invariant 1".
The "Build Status" markup badge had not been updated to refect the
change of CI systems from TravisCI to GitHub Actions.
@sbosnick
Copy link
Contributor Author

This was mistakenly submitted on top of #419. It was intended to be a stand-alone change against master so I will close this one and resubmit it.

@sbosnick sbosnick closed this May 24, 2020
@sbosnick sbosnick deleted the fix_readme branch May 24, 2020 14:44
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