From dddd27118cd69091dddcbe0b8ab6139a5e8358a4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 2 Aug 2020 17:51:46 +0100 Subject: [PATCH] Writer: Fix quoting of table keys Looking only at the first character to decide how to quote is clearly a mistake. And if we end up using " we must do \-escaping. So replace this broken code. Instead, we now prefer ' if there is no ' in the key. Signed-off-by: Ian Jackson --- TOML-Tiny/lib/TOML/Tiny/Writer.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TOML-Tiny/lib/TOML/Tiny/Writer.pm b/TOML-Tiny/lib/TOML/Tiny/Writer.pm index 2d2b79b..ddd714f 100644 --- a/TOML-Tiny/lib/TOML/Tiny/Writer.pm +++ b/TOML-Tiny/lib/TOML/Tiny/Writer.pm @@ -168,10 +168,10 @@ sub to_toml_key { return $str; } - if ($str =~ /^"/) { + if ($str !~ /'/) { return qq{'$str'}; } else { - return qq{"$str"}; + return to_toml_string($str); } } -- 2.30.2