summaryrefslogtreecommitdiff
path: root/std/encoding
diff options
context:
space:
mode:
authorJarrett Helton <jaydhelton@gmail.com>2020-08-03 13:26:02 -0400
committerGitHub <noreply@github.com>2020-08-03 13:26:02 -0400
commitd615ebefe2e306f2877afb40dc603f71263407d6 (patch)
tree669d1b325ebc534de3adba10e839375cc679a8f9 /std/encoding
parente9d713c007afd31e22c9edf2b256197ed12336f2 (diff)
fix(std/toml): parser error with inline comments (#6942)
Diffstat (limited to 'std/encoding')
-rw-r--r--std/encoding/testdata/boolean.toml3
-rw-r--r--std/encoding/toml.ts2
-rw-r--r--std/encoding/toml_test.ts2
3 files changed, 4 insertions, 3 deletions
diff --git a/std/encoding/testdata/boolean.toml b/std/encoding/testdata/boolean.toml
index 242d29c96..e3e287981 100644
--- a/std/encoding/testdata/boolean.toml
+++ b/std/encoding/testdata/boolean.toml
@@ -1,3 +1,4 @@
[boolean] # i hate comments
bool1 = true
-bool2 = false \ No newline at end of file
+bool2 = false
+bool3 = true # I love comments \ No newline at end of file
diff --git a/std/encoding/toml.ts b/std/encoding/toml.ts
index 43788c06a..336af97fb 100644
--- a/std/encoding/toml.ts
+++ b/std/encoding/toml.ts
@@ -280,7 +280,7 @@ class Parser {
return dataString.slice(0, endOfString);
}
- const m = /(?:|\[|{|).*(?:|\]||})\s*[^#]/g.exec(dataString);
+ const m = /(?:|\[|{).*(?:|\]|})\s*^((?!#).)*/g.exec(dataString);
if (m) {
return m[0].trim();
} else {
diff --git a/std/encoding/toml_test.ts b/std/encoding/toml_test.ts
index 45d0a66e6..0a927cde9 100644
--- a/std/encoding/toml_test.ts
+++ b/std/encoding/toml_test.ts
@@ -48,7 +48,7 @@ Deno.test({
Deno.test({
name: "[TOML] Boolean",
fn(): void {
- const expected = { boolean: { bool1: true, bool2: false } };
+ const expected = { boolean: { bool1: true, bool2: false, bool3: true } };
const actual = parseFile(path.join(testFilesDir, "boolean.toml"));
assertEquals(actual, expected);
},