From de37405f8e77eb111396c90298480870d40617d2 Mon Sep 17 00:00:00 2001 From: Alon Ziv Date: Sun, 8 Dec 2024 06:32:20 +0000 Subject: [PATCH] Re-enable bare `` when incompatibleImprovements < 2.3.34. --- freemarker-core/src/main/javacc/freemarker/core/FTL.jj | 4 +++- .../src/test/java/freemarker/core/SepParsingBugTest.java | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/freemarker-core/src/main/javacc/freemarker/core/FTL.jj b/freemarker-core/src/main/javacc/freemarker/core/FTL.jj index 72c191de7..c517271c1 100644 --- a/freemarker-core/src/main/javacc/freemarker/core/FTL.jj +++ b/freemarker-core/src/main/javacc/freemarker/core/FTL.jj @@ -943,7 +943,9 @@ TOKEN: | "items" ()+ > { handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); } | - "sep" > { handleTagSyntaxAndSwitch(matchedToken, DEFAULT); } + "sep" > { + if (incompatibleImprovements >= _VersionInts.V_2_3_24) handleTagSyntaxAndSwitch(matchedToken, DEFAULT); + } | "for" ("e" | "E") "ach" > { handleTagSyntaxAndSwitch(matchedToken, getTagNamingConvention(matchedToken, 3), FM_EXPRESSION); diff --git a/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java b/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java index f85e841cb..3e835d769 100644 --- a/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java +++ b/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java @@ -31,6 +31,7 @@ public class SepParsingBugTest extends TemplateTest { @Test public void testAutodetectTagSyntax() throws TemplateException, IOException { + getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24); getConfiguration().setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX); assertOutput("<#list [1, 2] as i>${i}<#sep>, ", "1, 2"); assertOutput("[#list [1, 2] as i]${i}[#sep], [/#list]", "1, 2"); @@ -42,6 +43,7 @@ public void testAutodetectTagSyntax() throws TemplateException, IOException { @Test public void testAngleBracketsTagSyntax() throws TemplateException, IOException { + getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24); getConfiguration().setTagSyntax(Configuration.ANGLE_BRACKET_TAG_SYNTAX); assertOutput("<#list [1, 2] as i>${i}<#sep>, ", "1, 2"); assertOutput("[#list [1, 2] as i]${i!'-'}[#sep], [/#list]", "[#list [1, 2] as i]-[#sep], [/#list]"); @@ -53,6 +55,7 @@ public void testAngleBracketsTagSyntax() throws TemplateException, IOException { @Test public void testSquareBracketTagSyntax() throws TemplateException, IOException { + getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24); getConfiguration().setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX); assertOutput("<#list [1, 2] as i>${i!'-'}<#sep>, ", "<#list [1, 2] as i>-<#sep>, "); assertOutput("[#list [1, 2] as i]${i}[#sep], [/#list]", "1, 2"); @@ -62,4 +65,10 @@ public void testSquareBracketTagSyntax() throws TemplateException, IOException { assertErrorContains("[#sep]", "#sep must be inside"); } + @Test + public void testLegacyTagSyntax() throws TemplateException, IOException { + getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_23); + getConfiguration().setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX); + assertOutput("<#list [1, 2] as i>${i}, ", "1, 2"); + } }