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

Audit use of unsafe in uri/mod.rs #417

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add more test of invalid UTF-8
  • Loading branch information
sbosnick committed Apr 24, 2020
commit 012680139221249ef71bdf0a37f8f2069afabd5d
10 changes: 10 additions & 0 deletions src/uri/tests.rs
Original file line number Diff line number Diff line change
@@ -555,4 +555,14 @@ fn test_uri_from_u8_slice_error() {
// invalid UTF-8
err(&[0xc0]);
err(&[b'h', b't', b't', b'p', b':', b'/', b'/', 0xc0]);
err(b"http://example.com/\0xc0");
err(b"http://example.com/path?\0xc0");
}

#[test]
fn test_uri_with_invalid_fragment_is_valid() {
let uri_bytes = b"http://example.com/path?query#\0xc0";
let uri = Uri::try_from(uri_bytes.as_ref()).expect("conversion error");

assert_eq!(uri, "http://example.com/path?query");
}