aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2017-07-08 18:43:36 +0200
committerBjørn Erik Pedersen <[email protected]>2017-07-08 18:43:36 +0200
commit7f82b41a24af0fd04d28fbfebf9254766a3c6e6f (patch)
tree4f83d4af30e083f3503bab80b0e5d8268c24a01d /parser
parent84db6c74a084d2b52117b999d4ec343cd3389a68 (diff)
downloadhugo-7f82b41a24af0fd04d28fbfebf9254766a3c6e6f.tar.gz
hugo-7f82b41a24af0fd04d28fbfebf9254766a3c6e6f.zip
parser: Final (!) fix for issue with escaped JSON front matter
Fixes #3682
Diffstat (limited to 'parser')
-rw-r--r--parser/page.go5
-rw-r--r--parser/parse_frontmatter_test.go2
2 files changed, 6 insertions, 1 deletions
diff --git a/parser/page.go b/parser/page.go
index f17ba1767..1537915f4 100644
--- a/parser/page.go
+++ b/parser/page.go
@@ -337,7 +337,6 @@ func extractFrontMatterDelims(r *bufio.Reader, left, right []byte) (fm []byte, e
if escapeState != 1 {
inQuote = !inQuote
}
- escapeState = 0
case '\\':
escapeState++
case left[len(left)-1]:
@@ -403,6 +402,10 @@ func extractFrontMatterDelims(r *bufio.Reader, left, right []byte) (fm []byte, e
return buf.Bytes(), nil
}
+ if c != '\\' {
+ escapeState = 0
+ }
+
}
}
diff --git a/parser/parse_frontmatter_test.go b/parser/parse_frontmatter_test.go
index b7764ca2d..14e69abfd 100644
--- a/parser/parse_frontmatter_test.go
+++ b/parser/parse_frontmatter_test.go
@@ -305,6 +305,8 @@ func TestExtractFrontMatterDelim(t *testing.T) {
{`{ "title": "\"Foo\"" }`, `{ "title": "\"Foo\"" }`, noErrExpected},
{`{ "title": "\"Foo\"\"" }`, `{ "title": "\"Foo\"\"" }`, noErrExpected},
{`{ "url": "http:\/\/example.com\/play\/url?id=1" }`, `{ "url": "http:\/\/example.com\/play\/url?id=1" }`, noErrExpected},
+ {`{ "test": "\"New\r\nString\"" }`, `{ "test": "\"New\r\nString\"" }`, noErrExpected},
+ {`{ "test": "RTS\/RPG" }`, `{ "test": "RTS\/RPG" }`, noErrExpected},
}
for i, test := range tests {