Bug report: assertion failure in the `index` function in the `url/src/slicing.rs` file.
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.6k
- Forks
- 406
- PR merge metrics
- No merged PRs in 30d
Description
- Note that this crate implements the URL Standard not RFC 1738 or RFC 3986
Describe the bug
There appears to be an assertion failure in the index function in the url/src/slicing.rs file.
Error message and stack backtrace
running 1 test
test fast_test2 ... FAILED
successes:
successes:
failures:
---- fast_test2 stdout ----
test="http://userDpass@mozilla.org"
sliced: ""
sliced: "http"
sliced: "http://"
sliced: "http://userDpass"
thread 'fast_test2' panicked at url/src/slicing.rs:147:21:
assertion failed: self.username_end == self.host_start
stack backtrace:
0: rust_begin_unwind
at /rustc/5069856495870486134dd2ca0b0e2516308c5c2a/library/std/src/panicking.rs:665:5
1: core::panicking::panic_fmt
at /rustc/5069856495870486134dd2ca0b0e2516308c5c2a/library/core/src/panicking.rs:74:14
2: core::panicking::panic
at /rustc/5069856495870486134dd2ca0b0e2516308c5c2a/library/core/src/panicking.rs:148:5
3: url::slicing::<impl url::Url>::index
at ./src/slicing.rs:147:21
4: url::slicing::<impl core::ops::index::Index<core::ops::range::Range<url::slicing::Position>> for url::Url>::index
at ./src/slicing.rs:36:54
5: fuzz_test2::fast_test2
at ./tests/fuzz_test2.rs:120:33
6: fuzz_test2::fast_test2::{{closure}}
at ./tests/fuzz_test2.rs:90:16
7: core::ops::function::FnOnce::call_once
at /rustc/5069856495870486134dd2ca0b0e2516308c5c2a/library/core/src/ops/function.rs:250:5
8: core::ops::function::FnOnce::call_once
at /rustc/5069856495870486134dd2ca0b0e2516308c5c2a/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
failures:
fast_test2
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.08s
error: test failed, to rerun pass `-p url --test fuzz_test2`
How to reproduce
- select any inputs in the example below
- run the test
let data = "http://userDpass@mozilla.org";
// let data = "httM://userpQass@mozilla.org";
// let data = "https://username;password@www.eample.c/m:8080/p)ath/to/opage?query=example#fragment";
// let data = "https://usernamepassword@wbww.examplencom:080/path/to/page?query=example\"fragmenkt";
// let data = "https://usernamepassword@www.example.com:8280/path/to/page?query=example#fragment";
println!("test={:?}", data);
if let Ok(url) = Url::parse(data) {
let positions = [
Position::BeforeScheme,
Position::AfterScheme,
Position::BeforeUsername,
Position::AfterUsername,
Position::BeforePassword,
Position::AfterPassword,
Position::BeforeHost,
Position::AfterHost,
Position::BeforePort,
Position::AfterPort,
Position::BeforePath,
Position::AfterPath,
Position::BeforeQuery,
Position::AfterQuery,
Position::BeforeFragment,
Position::AfterFragment,
];
// Attempt to create slices of the URL using all "good" combinations of positions
for (i, &start) in positions.iter().enumerate() {
for &end in &positions[i..] {
let slice = &url[start..end];
println!("sliced: {:?}", slice);
}
}
} else {
println!("Invalid URL");
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in url/src/slicing.rs at Url::index and reproduce the assertion with the input shown in the issue. Run the fast_test2 case in tests/fuzz_test2.rs and inspect the reported position relationships. Done means the listed URL slices no longer trigger the assertion while the test continues to pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100