diff options
author | pommicket <pommicket@gmail.com> | 2025-09-09 00:48:56 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-09-09 00:48:56 -0400 |
commit | eae80ef227870382b4d76168866f9683e93e84f3 (patch) | |
tree | deff14a734a5f4981425cc11d44409a7e0d75927 /src/lib.rs | |
parent | e3a4ef53a75bc10129010cf18fb7ce68a6acbf2a (diff) |
Fix \u{0} being accepted; errors tests
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() } |