From 37dd61b21736afeca67dd04ae9f2804853b20696 Mon Sep 17 00:00:00 2001 From: George Petrov Date: Sun, 14 Jan 2024 11:40:50 +0100 Subject: [PATCH 1/2] Require quoting for keys containing At Sign Currently when minimal quoting is specified, keys containing @ sign are not quoted, but then should be. --- lib/hjson-stringify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hjson-stringify.js b/lib/hjson-stringify.js index 6d800af..971b3af 100644 --- a/lib/hjson-stringify.js +++ b/lib/hjson-stringify.js @@ -111,7 +111,7 @@ module.exports = function(data, opt) { '"' : '"', '\\': '\\' }; - var needsEscapeName = /[,\{\[\}\]\s:#"']|\/\/|\/\*/; + var needsEscapeName = /[,\{\[\}\]\s@:#"']|\/\/|\/\*/; var gap = ''; // var wrapLen = 0; From d271b26bce5654450c4aa87f4889a70179b8496f Mon Sep 17 00:00:00 2001 From: George Petrov Date: Sat, 17 Feb 2024 19:11:36 +0100 Subject: [PATCH 2/2] Also require quoting for keys containing dashes --- lib/hjson-stringify.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hjson-stringify.js b/lib/hjson-stringify.js index 971b3af..7b61b43 100644 --- a/lib/hjson-stringify.js +++ b/lib/hjson-stringify.js @@ -111,7 +111,7 @@ module.exports = function(data, opt) { '"' : '"', '\\': '\\' }; - var needsEscapeName = /[,\{\[\}\]\s@:#"']|\/\/|\/\*/; + var needsEscapeName = /[,\{\[\}\]\s@\-:#"']|\/\/|\/\*/; var gap = ''; // var wrapLen = 0;