From eae80ef227870382b4d76168866f9683e93e84f3 Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 9 Sep 2025 00:48:56 -0400 Subject: Fix \u{0} being accepted; errors tests --- src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 56ecb61..f75389b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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() } -- cgit v1.2.3