From 1e91e46520e980a15a46beeb6d5ae846e17a9144 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 16 Oct 2025 16:42:49 +0200 Subject: [PATCH] parser/pageparser: Fix shortcode nesting regression This reverts commit a133393edab5aca89b60fae44e445bc527095c6a. While that commit fixed a bug, it introduced a worse one. Closes #14054 --- parser/pageparser/pagelexer_shortcode.go | 3 +-- parser/pageparser/pageparser_shortcode_test.go | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/parser/pageparser/pagelexer_shortcode.go b/parser/pageparser/pagelexer_shortcode.go index 3a656263a..5d3c55eeb 100644 --- a/parser/pageparser/pagelexer_shortcode.go +++ b/parser/pageparser/pagelexer_shortcode.go @@ -263,12 +263,11 @@ Loop: } l.openShortcodes[word] = false lookForEnd = true - } else { - l.openShortcodes[word] = true } l.closingState = 0 l.currShortcodeName = word.Value() + l.openShortcodes[word] = true l.elementStepNum++ if l.isInline { l.emit(tScNameInline) diff --git a/parser/pageparser/pageparser_shortcode_test.go b/parser/pageparser/pageparser_shortcode_test.go index 7d14b15e8..29626b6ad 100644 --- a/parser/pageparser/pageparser_shortcode_test.go +++ b/parser/pageparser/pageparser_shortcode_test.go @@ -27,7 +27,6 @@ var ( tstRightMD = nti(tRightDelimScWithMarkup, "%}}") tstSCClose = nti(tScClose, "/") tstSC1 = nti(tScName, "sc1") - tstSCAnother = nti(tScName, "another") tstSC1Inline = nti(tScNameInline, "sc1.inline") tstSC2Inline = nti(tScNameInline, "sc2.inline") tstSC2 = nti(tScName, "sc2") @@ -75,10 +74,6 @@ var shortCodeLexerTests = []lexerTest{ tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose, nti(tError, "closing tag for shortcode 'another' does not match start tag"), }, nil}, - {"close wrong, repeated", `{{< sc1 >}}{{< another >}}{{< /another >}}{{< /another >}}`, []typeText{ - tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCAnother, tstRightNoMD, tstLeftNoMD, tstSCClose, tstSCAnother, tstRightNoMD, tstLeftNoMD, tstSCClose, - nti(tError, "closing tag for shortcode 'another' does not match start tag"), - }, nil}, {"close, but no open, more", `{{< sc1 >}}{{< /sc1 >}}{{< /another >}}`, []typeText{ tstLeftNoMD, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose, tstSC1, tstRightNoMD, tstLeftNoMD, tstSCClose, nti(tError, "closing tag for shortcode 'another' does not match start tag"), -- 2.39.5