ref: 14c35c8a56c4dc9a1ee0053e9ff976be7715ba99
parent: 96689a5c319f720368491226f034d0ff9585217c
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Wed Apr 11 18:41:48 EDT 2018
Allow "*/" inside commented out shortcodes Fixes #4608
--- a/hugolib/shortcodeparser.go
+++ b/hugolib/shortcodeparser.go
@@ -312,7 +312,7 @@
}
func lexShortcodeComment(l *pagelexer) stateFunc {- posRightComment := strings.Index(l.input[l.pos:], rightComment)
+ posRightComment := strings.Index(l.input[l.pos:], rightComment+l.currentRightShortcodeDelim())
if posRightComment <= 1 { return l.errorf("comment must be closed")}
@@ -324,9 +324,6 @@
l.emit(tText)
l.pos += pos(len(rightComment))
l.ignore()
- if !strings.HasPrefix(l.input[l.pos:], l.currentRightShortcodeDelim()) {- return l.errorf("comment ends before the right shortcode delimiter")- }
l.pos += pos(len(l.currentRightShortcodeDelim()))
l.emit(tText)
return lexTextOutsideShortcodes
--- a/hugolib/shortcodeparser_test.go
+++ b/hugolib/shortcodeparser_test.go
@@ -145,10 +145,12 @@
{tError, 0, "got named parameter 'param2'. Cannot mix named and positional parameters"}}}, {"commented out", `{{</* sc1 */>}}`, []item{ {tText, 0, "{{<"}, {tText, 0, " sc1 "}, {tText, 0, ">}}"}, tstEOF}},+ {"commented out, with asterisk inside", `{{</* sc1 "**/*.pdf" */>}}`, []item{+ {tText, 0, "{{<"}, {tText, 0, " sc1 \"**/*.pdf\" "}, {tText, 0, ">}}"}, tstEOF}}, {"commented out, missing close", `{{</* sc1 >}}`, []item{ {tError, 0, "comment must be closed"}}}, {"commented out, misplaced close", `{{</* sc1 >}}*/`, []item{- {tText, 0, "{{<"}, {tText, 0, " sc1 >}}"}, {tError, 0, "comment ends before the right shortcode delimiter"}}},+ {tError, 0, "comment must be closed"}}},}
func TestShortcodeLexer(t *testing.T) {--
⑨