This repository was archived by the owner on Mar 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -556,11 +556,11 @@ where
556556 return visitor. visit_i64 ( n) ;
557557 }
558558 }
559- // After handling the different number encodings above
560- // if we are left with leading zero(s) followed by numeric characters
561- // this is in fact a string according to the YAML 1.2 spec
562- // https://yaml.org/spec/ 1.2/ spec.html#id2761292
563- if v . len ( ) > 1 && v . starts_with ( '0' ) && v . chars ( ) . all ( char :: is_numeric ) {
559+ if v . len ( ) > 1 && v . starts_with ( '0' ) && v . bytes ( ) . all ( |b| b . is_ascii_digit ( ) ) {
560+ // After handling the different number encodings above if we are left
561+ // with leading zero(s) followed by numeric characters this is in fact a
562+ // string according to the YAML 1.2 spec.
563+ // https://yaml.org/spec/1.2/spec.html#id2761292
564564 return visitor. visit_str ( v) ;
565565 }
566566 if let Ok ( n) = v. parse ( ) {
Original file line number Diff line number Diff line change @@ -10,11 +10,14 @@ fn test_nan() {
1010 let neg_fake_nan = serde_yaml:: from_str :: < Value > ( "-.nan" ) . unwrap ( ) ;
1111 assert ! ( neg_fake_nan. is_string( ) ) ;
1212
13- let num_string = serde_yaml:: from_str :: < Value > ( "01" ) . unwrap ( ) ;
14- assert ! ( num_string. is_string( ) ) ;
15-
1613 let significand_mask = 0xF_FFFF_FFFF_FFFF ;
1714 let bits = ( f64:: NAN . to_bits ( ) ^ significand_mask) | 1 ;
1815 let different_pos_nan = Value :: Number ( Number :: from ( f64:: from_bits ( bits) ) ) ;
1916 assert_eq ! ( pos_nan, different_pos_nan) ;
2017}
18+
19+ #[ test]
20+ fn test_digits ( ) {
21+ let num_string = serde_yaml:: from_str :: < Value > ( "01" ) . unwrap ( ) ;
22+ assert ! ( num_string. is_string( ) ) ;
23+ }
You can’t perform that action at this time.
0 commit comments