From 840028c64f42764a9b9972bc6ec68aefc760a599 Mon Sep 17 00:00:00 2001 From: Pascal Scholz Date: Mon, 13 Jul 2026 17:19:01 +0200 Subject: [PATCH] option_parser: Reject `Tuple` keys only consisting of whitespaace We reject keys only consisting of whitespace as empty as it can occur as an input artifact. Signed-off-by: Pascal Scholz On-behalf-of: SAP pascal.scholz@sap.com --- option_parser/src/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/option_parser/src/lib.rs b/option_parser/src/lib.rs index cb6a496b8..199b2f1d2 100644 --- a/option_parser/src/lib.rs +++ b/option_parser/src/lib.rs @@ -966,6 +966,17 @@ mod unit_tests { ); } + #[test] + fn test_tuple_reject_whitespace_as_empty_key() { + let expected_value = "@42"; + let e = Tuple::::from_str(" @42").unwrap_err(); + assert!( + matches!(e, TupleError::EmptyKey(ref s) if s == expected_value), + "Expected \"{:?}\"; got \"{e:?}\"", + TupleError::EmptyKey(expected_value.to_string()), + ); + } + #[test] fn test_split_commas_unbalanced_bracket() { split_commas("[a,b").unwrap_err();