Skip to content

Commit

Permalink
Revert "Fix path double percent parsing (#233)"
Browse files Browse the repository at this point in the history
This reverts commit c935888.

As written, the double percent special case breaks out of the check
loop, thereby allowing any characters in the path after that point.
  • Loading branch information
dekellum authored and seanmonstar committed Sep 18, 2018
1 parent a1c3f4b commit 1a6f904
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/uri/path.rs
Expand Up @@ -49,11 +49,6 @@ impl PathAndQuery {
match URI_CHARS[b as usize] {
0 => {
if b == b'%' {
// Check if next character is not %
if i + 2 <= src.len() && b'%' == src[i + 1] {
break;
}

// Check that there are enough chars for a percent
// encoded char
let perc_encoded =
Expand Down Expand Up @@ -522,32 +517,4 @@ mod tests {
assert!(path_and_query > "/a/world&foo=bar".to_string());
assert!("/a/world&foo=bar".to_string() < path_and_query);
}

#[test]
fn double_percent_path() {
let double_percent_path = "/your.js?bn=%%val";

assert!(double_percent_path.parse::<PathAndQuery>().is_ok());

let path: PathAndQuery = double_percent_path.parse().unwrap();
assert_eq!(path, double_percent_path);

let double_percent_path = "/path%%";

assert!(double_percent_path.parse::<PathAndQuery>().is_ok());
}

#[test]
fn path_ends_with_question_mark() {
let path = "/path?%";

assert!(path.parse::<PathAndQuery>().is_err());
}

#[test]
fn path_ends_with_fragment_percent() {
let path = "/path#%";

assert!(path.parse::<PathAndQuery>().is_ok());
}
}

0 comments on commit 1a6f904

Please sign in to comment.