Skip to content

Commit

Permalink
Do not %-encode ^ and ~ characters
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez authored and marcusklaas committed May 20, 2022
1 parent 9bfba94 commit 27f7cd5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ static HREF_SAFE: [u8; 128] = [
0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1,
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0,
];

static HEX_CHARS: &[u8] = b"0123456789ABCDEF";
Expand Down Expand Up @@ -354,3 +354,15 @@ mod simd {
}
}
}

#[cfg(test)]
mod test {
pub use super::escape_href;

#[test]
fn check_href_escape() {
let mut s = String::new();
escape_href(&mut s, "&^_").unwrap();
assert_eq!(s.as_str(), "&^_");
}
}

0 comments on commit 27f7cd5

Please sign in to comment.