From 32d59b8c78c55c9681bc850a062dae87b29dd90f Mon Sep 17 00:00:00 2001 From: "Levy A." Date: Thu, 17 Apr 2025 20:08:05 -0300 Subject: [PATCH 1/2] refactor+fix: using a more robust pattern matching approach --- core/util.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/core/util.rs b/core/util.rs index b3ce8ecd0..295989cee 100644 --- a/core/util.rs +++ b/core/util.rs @@ -878,11 +878,7 @@ fn parse_numeric_str(text: &str) -> Result<(OwnedValueType, &str), ()> { let text = text.trim(); let bytes = text.as_bytes(); - if bytes.is_empty() - || bytes[0] == b'e' - || bytes[0] == b'E' - || (bytes[0] == b'.' && (bytes[1] == b'e' || bytes[1] == b'E')) - { + if matches!(bytes, [b'e', ..] | [b'E', ..] | [b'.', b'e' | b'E', ..]) { return Err(()); } From 5fd2ed0bae42036128ee34e348ce3c7f2af810e9 Mon Sep 17 00:00:00 2001 From: "Levy A." Date: Thu, 17 Apr 2025 20:20:57 -0300 Subject: [PATCH 2/2] fix: handle empty case --- core/util.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/util.rs b/core/util.rs index 295989cee..82c7cb3c2 100644 --- a/core/util.rs +++ b/core/util.rs @@ -878,7 +878,10 @@ fn parse_numeric_str(text: &str) -> Result<(OwnedValueType, &str), ()> { let text = text.trim(); let bytes = text.as_bytes(); - if matches!(bytes, [b'e', ..] | [b'E', ..] | [b'.', b'e' | b'E', ..]) { + if matches!( + bytes, + [] | [b'e', ..] | [b'E', ..] | [b'.', b'e' | b'E', ..] + ) { return Err(()); }