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

Bug report: assertion failure in the index function in the url/src/slicing.rs file. #973

Open
1 task done
yunji-yunji opened this issue Sep 23, 2024 · 0 comments
Open
1 task done

Comments

@yunji-yunji
Copy link

  • 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://[email protected]"
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

  1. select any inputs in the example below
  2. run the test
    let data = "http://[email protected]";
    // let data = "httM://[email protected]";
    // let data = "https://username;[email protected]/m:8080/p)ath/to/opage?query=example#fragment";
    // let data = "https://[email protected]:080/path/to/page?query=example\"fragmenkt";
    // let data = "https://[email protected]: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");
    }
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

No branches or pull requests

1 participant