diff options
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -445,10 +445,11 @@ impl Parser { .push(invalid_escape(format!("\\x{c1}{c2}"))); return; }; - if nibble1 == 0 && nibble2 == 0 { + let char_code = nibble1 << 4 | nibble2; + if char_code == 0 { self.nonfatal_errors.push(Error::InvalidValue(location())); } - value.push(char::try_from(nibble1 << 4 | nibble2).unwrap()); + value.push(char::try_from(char_code).unwrap()); } 'u' => { let mut c = chars.next(); @@ -481,6 +482,9 @@ impl Parser { .push(invalid_escape("\\u{ has no matching }".into())); return; } + if code == 0 { + self.nonfatal_errors.push(Error::InvalidValue(location())); + } let Ok(c) = char::try_from(code) else { self.nonfatal_errors .push(invalid_escape(format!("\\u{{{code:x}}}"))); @@ -717,7 +721,7 @@ impl Configuration { /// /// The order of items returned is arbitrary and may change /// in future versions without notice. - pub fn iter(&self) -> ConfigurationIter { + pub fn iter(&self) -> ConfigurationIter<'_> { self.into_iter() } |