From: Ian Jackson Date: Sun, 2 Aug 2020 16:51:46 +0000 (+0100) Subject: Writer: Fix quoting of table keys X-Git-Tag: nailing-cargo/1.0.0~63 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=dddd27118cd69091dddcbe0b8ab6139a5e8358a4;p=nailing-cargo.git 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 --- 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); } }