@@ -877,15 +877,13 @@ fn parse_escape<'de, R: Read<'de>>(
877
877
b'r' => scratch. push ( b'\r' ) ,
878
878
b't' => scratch. push ( b'\t' ) ,
879
879
b'u' => return parse_unicode_escape ( read, validate, scratch) ,
880
- _ => {
881
- return error ( read, ErrorCode :: InvalidEscape ) ;
882
- }
880
+ _ => return error ( read, ErrorCode :: InvalidEscape ) ,
883
881
}
884
882
885
883
Ok ( ( ) )
886
884
}
887
885
888
- /// Parses a JSON \u escape and appends it into the scratch space. Assumes \u
886
+ /// Parses a JSON \u escape and appends it into the scratch space. Assumes `\u`
889
887
/// has just been read.
890
888
#[ cold]
891
889
fn parse_unicode_escape < ' de , R : Read < ' de > > (
@@ -895,10 +893,10 @@ fn parse_unicode_escape<'de, R: Read<'de>>(
895
893
) -> Result < ( ) > {
896
894
let mut n = tri ! ( read. decode_hex_escape( ) ) ;
897
895
898
- // Non-BMP characters are encoded as a sequence of two hex
899
- // escapes, representing UTF-16 surrogates. If deserializing a
900
- // utf-8 string the surrogates are required to be paired,
901
- // whereas deserializing a byte string accepts lone surrogates.
896
+ // Non-BMP characters are encoded as a sequence of two hex escapes,
897
+ // representing UTF-16 surrogates. If deserializing a utf-8 string the
898
+ // surrogates are required to be paired, whereas deserializing a byte string
899
+ // accepts lone surrogates.
902
900
if validate && n >= 0xDC00 && n <= 0xDFFF {
903
901
// XXX: This is actually a trailing surrogate.
904
902
return error ( read, ErrorCode :: LoneLeadingSurrogateInHexEscape ) ;
@@ -935,11 +933,10 @@ fn parse_unicode_escape<'de, R: Read<'de>>(
935
933
error ( read, ErrorCode :: UnexpectedEndOfHexEscape )
936
934
} else {
937
935
push_wtf8_codepoint ( n1 as u32 , scratch) ;
938
- // The \ prior to this byte started an escape sequence,
939
- // so we need to parse that now. This recursive call
940
- // does not blow the stack on malicious input because
941
- // the escape is not \u, so it will be handled by one
942
- // of the easy nonrecursive cases.
936
+ // The \ prior to this byte started an escape sequence, so we
937
+ // need to parse that now. This recursive call does not blow the
938
+ // stack on malicious input because the escape is not \u, so it
939
+ // will be handled by one of the easy nonrecursive cases.
943
940
parse_escape ( read, validate, scratch)
944
941
} ;
945
942
}
@@ -956,8 +953,8 @@ fn parse_unicode_escape<'de, R: Read<'de>>(
956
953
continue ;
957
954
}
958
955
959
- // This value is in range U+10000..=U+10FFFF, which is always a
960
- // valid codepoint.
956
+ // This value is in range U+10000..=U+10FFFF, which is always a valid
957
+ // codepoint.
961
958
let n = ( ( ( n1 - 0xD800 ) as u32 ) << 10 | ( n2 - 0xDC00 ) as u32 ) + 0x1_0000 ;
962
959
push_wtf8_codepoint ( n, scratch) ;
963
960
return Ok ( ( ) ) ;
0 commit comments