You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, this is the first of the other issues that I mentioned in #1454.
Many tests in the test suite are failing because the Url crate will erroneously parse a windows filebath with a drive specifier as a url. An example of the test results are included below. Note in particular the Network Errors caused by 'URL Scheme is not allowed'.
FAIL [ 0.565s] lychee::example_domains cli::test_do_not_exclude_false_positive_example_domains
--- STDOUT: lychee::example_domains cli::test_do_not_exclude_false_positive_example_domains ---
running 1 test
test cli::test_do_not_exclude_false_positive_example_domains ... FAILED
failures:
failures:
cli::test_do_not_exclude_false_positive_example_domains
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.55s
--- STDERR: lychee::example_domains cli::test_do_not_exclude_false_positive_example_domains ---
thread 'cli::test_do_not_exclude_false_positive_example_domains' panicked at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\ops\function.rs:250:5:
Unexpected failure.
code=1
stderr=``````
Error: Network error
Caused by:
0: builder error for url (c:\\Users\\bnhei\\source\\repos\\lychee\\fixtures\\TEST_EXAMPLE_DOMAINS_FALSE_POSITIVES.md)
1: URL scheme is not allowed
command=`"C:\\Users\\bnhei\\source\\repos\\lychee\\target\\debug\\lychee.exe" "C:\\Users\\bnhei\\source\\repos\\lychee\\fixtures\\TEST_EXAMPLE_DOMAINS_FALSE_POSITIVES.md" "--include-mail" "--dump"`
code=1
stdout=""
stderr=```
Error: Network error
Caused by:
0: builder error for url (c:\\Users\\bnhei\\source\\repos\\lychee\\fixtures\\TEST_EXAMPLE_DOMAINS_FALSE_POSITIVES.md)
1: URL scheme is not allowed
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Canceling due to test failure: 7 tests still running
FAIL [ 0.574s] lychee::data_uris cli::test_dump_data_uris_in_verbose_mode
pubfn new(value:&str,file_type_hint:Option<FileType>,glob_ignore_case:bool,excluded_paths:Option<Vec<PathBuf>>,) -> Result<Self>{let source = if value == STDIN{InputSource::Stdin}elseifletOk(url) = Url::parse(value){// <-- HEREInputSource::RemoteUrl(Box::new(url))}else{// file handling here
When I checked this in my debugger, I indeed found that Windows filepaths were being identified as Urls:
[lychee-lib\\src\\types\\input.rs:136:9] url = Url {
scheme: \"c\", // <-- HERE, scheme is c. The file path that I provided was C://etc/etc
cannot_be_a_base: true,
username: \"\",
password: None,
host: None,
port: None,
path: \"\\\\Users\\\\{my-username}\\\\AppData\\\\Local\\\\Temp\\\\.tmpS5lXlI\",
query: None,
fragment: None,
}
Short Term Solution
In my investigation, I found that the reqwest crate's RequestBuilder struct will error if you try to construct a request using such a url, so I made a minor, if inelegant modification to the function:
pub fn new(
value: &str,
file_type_hint: Option<FileType>,
glob_ignore_case: bool,
excluded_paths: Option<Vec<PathBuf>>,
) -> Result<Self> {
let source = if value == STDIN {
InputSource::Stdin
} else if Request::builder().uri(value).body(()).is_ok() {
let url = Url::parse(value)
.map_err(|err| crate::ErrorKind::ParseUrl(err, value.to_owned()))?;
InputSource::RemoteUrl(Box::new(url))
} else {
Something better could be worked out in the future, but for now this does the trick. Will submit a PR for this soon.
In any case, with the above change, our test output on Windows changes to this:
Hello, this is the first of the other issues that I mentioned in #1454.
Many tests in the test suite are failing because the Url crate will erroneously parse a windows filebath with a drive specifier as a url. An example of the test results are included below. Note in particular the Network Errors caused by 'URL Scheme is not allowed'.
note: run with
RUST_BACKTRACE=1
environment variable to display a backtraceCanceling due to test failure: 7 tests still running
FAIL [ 0.574s] lychee::data_uris cli::test_dump_data_uris_in_verbose_mode
--- STDOUT: lychee::data_uris cli::test_dump_data_uris_in_verbose_mode ---
running 1 test
test cli::test_dump_data_uris_in_verbose_mode ... FAILED
failures:
failures:
cli::test_dump_data_uris_in_verbose_mode
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.56s
--- STDERR: lychee::data_uris cli::test_dump_data_uris_in_verbose_mode ---
thread 'cli::test_dump_data_uris_in_verbose_mode' panicked at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\ops\function.rs:250:5:
Unexpected failure.
code=1
stderr=``````
Error: Network error
Caused by:
0: builder error for url (c:\Users\bnhei\source\repos\lychee\fixtures\TEST_DATA_URIS.html)
1: URL scheme is not allowed
command=
"C:\\Users\\bnhei\\source\\repos\\lychee\\target\\debug\\lychee.exe" "C:\\Users\\bnhei\\source\\repos\\lychee\\fixtures\\TEST_DATA_URIS.html" "--dump" "--verbose"
code=1
stdout=""
stderr=```
Error: Network error
Caused by:
0: builder error for url (c:\Users\bnhei\source\repos\lychee\fixtures\TEST_DATA_URIS.html)
1: URL scheme is not allowed
note: run with
RUST_BACKTRACE=1
environment variable to display a backtrace--- STDOUT: lychee::local_files cli::test_local_dir ---
running 1 test
test cli::test_local_dir ... FAILED
failures:
failures:
cli::test_local_dir
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.55s
--- STDERR: lychee::local_files cli::test_local_dir ---
thread 'cli::test_local_dir' panicked at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\ops\function.rs:250:5:
Unexpected failure.
code=1
stderr=``````
Error: Network error
Caused by:
0: builder error for url (c:\Users\bnhei\AppData\Local\Temp\.tmpxxgIJG)
1: URL scheme is not allowed
command=
"C:\\Users\\bnhei\\source\\repos\\lychee\\target\\debug\\lychee.exe" "C:\\Users\\bnhei\\AppData\\Local\\Temp\\.tmpxxgIJG" "--no-progress" "--verbose"
code=1
stdout=""
stderr=```
Error: Network error
Caused by:
0: builder error for url (c:\Users\bnhei\AppData\Local\Temp\.tmpxxgIJG)
1: URL scheme is not allowed
note: run with
RUST_BACKTRACE=1
environment variable to display a backtrace--- STDOUT: lychee::example_domains cli::test_exclude_example_domains ---
running 1 test
test cli::test_exclude_example_domains ... FAILED
failures:
failures:
cli::test_exclude_example_domains
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 1 filtered out; finished in 0.56s
--- STDERR: lychee::example_domains cli::test_exclude_example_domains ---
thread 'cli::test_exclude_example_domains' panicked at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\core\src\ops\function.rs:250:5:
Unexpected failure.
code=1
stderr=``````
Error: Network error
Caused by:
0: builder error for url (c:\Users\bnhei\source\repos\lychee\fixtures\TEST_EXAMPLE_DOMAINS.md)
1: URL scheme is not allowed
command=
"C:\\Users\\bnhei\\source\\repos\\lychee\\target\\debug\\lychee.exe" "C:\\Users\\bnhei\\source\\repos\\lychee\\fixtures\\TEST_EXAMPLE_DOMAINS.md" "--include-mail" "--dump"
code=1
stdout=""
stderr=```
Error: Network error
Caused by:
0: builder error for url (c:\Users\bnhei\source\repos\lychee\fixtures\TEST_EXAMPLE_DOMAINS.md)
1: URL scheme is not allowed
I tracked this error to
Input::new
method.When I checked this in my debugger, I indeed found that Windows filepaths were being identified as Urls:
Short Term Solution
In my investigation, I found that the reqwest crate's RequestBuilder struct will error if you try to construct a request using such a url, so I made a minor, if inelegant modification to the function:
Something better could be worked out in the future, but for now this does the trick. Will submit a PR for this soon.
In any case, with the above change, our test output on Windows changes to this:
As you can see, there still remain some issues, but this still gets us a long way.
The text was updated successfully, but these errors were encountered: