Skip to content
This repository was archived by the owner on Mar 25, 2024. It is now read-only.

Commit ed53e36

Browse files
committed
Touch up PR 180
1 parent ce23aff commit ed53e36

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎src/de.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff 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() {

‎tests/test_value.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)