Skip to content

Commit

Permalink
Remove three unwraps from escaped_char
Browse files Browse the repository at this point in the history
  • Loading branch information
divergentdave committed May 14, 2020
1 parent b6cb073 commit 03c8f41
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/parser/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,22 +315,22 @@ fn escaped_char(input: &[u8]) -> IResult<&[u8], char> {
tag("\\"),
alt((
value('\\', tag("\\")),
map(
terminated(
recognize(many_m_n(
1,
6,
one_of("0123456789ABCDEFabcdef"),
)),
opt(tag(" ")),
map_opt(
map_res(
map_res(
terminated(
recognize(many_m_n(
1,
6,
one_of("0123456789ABCDEFabcdef"),
)),
opt(tag(" ")),
),
input_to_str,
),
|s| u32::from_str_radix(s, 16),
),
|hp| {
std::char::from_u32(
u32::from_str_radix(input_to_str(hp).unwrap(), 16)
.unwrap(),
)
.unwrap()
},
std::char::from_u32
),
take_char,
)),
Expand Down
10 changes: 10 additions & 0 deletions tests/fuzz_cases.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use rsass::{compile_scss, output};

#[test]
fn bad_escape() {
let format = output::Format {
style: output::Style::Compressed,
precision: 5,
};
assert!(compile_scss(b"\\d00000", format).is_err());
}

0 comments on commit 03c8f41

Please sign in to comment.