From 57f2e661b8db22491b404f0e515c362bc6d8a235 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 12 Dec 2021 20:16:53 -0800 Subject: [PATCH] Treat YAML 1.1 style octals with sign as string, not base 10 number --- src/de.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/de.rs b/src/de.rs index e5f21b06..bab38d13 100644 --- a/src/de.rs +++ b/src/de.rs @@ -987,7 +987,10 @@ where return visitor.visit_i64(n); } } - if v.len() > 1 && v.starts_with('0') && v.bytes().all(|b| b.is_ascii_digit()) { + if { + let v = v.trim_start_matches(&['-', '+'][..]); + v.len() > 1 && v.starts_with('0') && v[1..].bytes().all(|b| b.is_ascii_digit()) + } { // After handling the different number encodings above if we are left // with leading zero(s) followed by numeric characters this is in fact a // string according to the YAML 1.2 spec.