-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close a loophole in reference resolution algorithm
Also add more fuzz targets against `iri-string`
- Loading branch information
Showing
4 changed files
with
101 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#![no_main] | ||
use fluent_uri::Uri; | ||
use iri_string::{format::ToDedicatedString, types::UriStr}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: &str| { | ||
let Ok(u1) = Uri::parse(data) else { return }; | ||
|
||
if u1.is_relative_reference() || u1.path().is_rootless() { | ||
return; | ||
} | ||
|
||
let u2 = UriStr::new(data).unwrap(); | ||
|
||
let u1 = u1.normalize(); | ||
|
||
// if u1.path() == "/.//" { | ||
// return; | ||
// } | ||
|
||
assert_eq!(u1.as_str(), u2.normalize().to_dedicated_string().as_str()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![no_main] | ||
use fluent_uri::Uri; | ||
use iri_string::{ | ||
format::ToDedicatedString, | ||
types::{UriAbsoluteStr, UriReferenceStr}, | ||
}; | ||
use libfuzzer_sys::fuzz_target; | ||
|
||
fuzz_target!(|data: (&str, &str)| { | ||
let (Ok(base), Ok(r)) = (Uri::parse(data.0), Uri::parse(data.1)) else { | ||
return; | ||
}; | ||
|
||
if r.path().is_rootless() { | ||
return; | ||
} | ||
|
||
let Ok(u1) = r.resolve(&base) else { return }; | ||
|
||
// if u1.path() == "/.//" { | ||
// return; | ||
// } | ||
|
||
let base = UriAbsoluteStr::new(data.0).unwrap(); | ||
let r = UriReferenceStr::new(data.1).unwrap(); | ||
|
||
let u2 = r.resolve_against(base).to_dedicated_string(); | ||
|
||
assert_eq!(u1.as_str(), u2.as_str()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters