Skip to content

Commit

Permalink
Check char::from_u32 for invalid code point
Browse files Browse the repository at this point in the history
fix #75
  • Loading branch information
zonyitoo committed Sep 26, 2020
1 parent 8d5a92f commit 9a11ce1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ impl Ini {
let key = section_key!(section);
self.sections.remove(&key)
}

/// Delete the key from the section, return the value if key exists or None
pub fn delete_from<S>(&mut self, section: Option<S>, key: &str) -> Option<String>
where S: Into<String>
Expand Down Expand Up @@ -1133,7 +1133,12 @@ impl<'a> Parser<'a> {
}
let r = u32::from_str_radix(&code[..], 16);
match r {
Ok(c) => result.push(char::from_u32(c).unwrap()),
Ok(c) => match char::from_u32(c) {
Some(c) => result.push(c),
None => {
return self.error("unknown character in \\xHH form");
}
},
Err(_) => return self.error("unknown character in \\xHH form"),
}
}
Expand Down

0 comments on commit 9a11ce1

Please sign in to comment.