This is an automated email from the ASF dual-hosted git repository.

ddekany pushed a commit to branch 2.3-gae
in repository https://gitbox.apache.org/repos/asf/freemarker.git


The following commit(s) were added to refs/heads/2.3-gae by this push:
     new 55ffb5ef Adjusted last merged PR: incompatibleImprovements 2.3.24 -> 
2.3.34. Added more JUnit tests. Updated version history.
55ffb5ef is described below

commit 55ffb5ef92db6560fe8af9d087660f3e9d4ca75c
Author: ddekany <[email protected]>
AuthorDate: Sun Dec 8 14:57:57 2024 +0100

    Adjusted last merged PR: incompatibleImprovements 2.3.24 -> 2.3.34. Added 
more JUnit tests. Updated version history.
---
 .../main/java/freemarker/template/_VersionInts.java  |  1 +
 .../src/main/javacc/freemarker/core/FTL.jj           |  2 +-
 .../test/java/freemarker/core/SepParsingBugTest.java | 20 +++++++++++++++-----
 freemarker-manual/src/main/docgen/en_US/book.xml     | 20 +++++++++++++-------
 4 files changed, 30 insertions(+), 13 deletions(-)

diff --git 
a/freemarker-core/src/main/java/freemarker/template/_VersionInts.java 
b/freemarker-core/src/main/java/freemarker/template/_VersionInts.java
index 69ca09a7..b07c9bd7 100644
--- a/freemarker-core/src/main/java/freemarker/template/_VersionInts.java
+++ b/freemarker-core/src/main/java/freemarker/template/_VersionInts.java
@@ -47,5 +47,6 @@ public final class _VersionInts {
     public static final int V_2_3_31 = Configuration.VERSION_2_3_31.intValue();
     public static final int V_2_3_32 = Configuration.VERSION_2_3_32.intValue();
     public static final int V_2_3_33 = Configuration.VERSION_2_3_33.intValue();
+    public static final int V_2_3_34 = Configuration.VERSION_2_3_34.intValue();
     public static final int V_2_4_0 = Version.intValueFor(2, 4, 0);
 }
diff --git a/freemarker-core/src/main/javacc/freemarker/core/FTL.jj 
b/freemarker-core/src/main/javacc/freemarker/core/FTL.jj
index c517271c..316372ea 100644
--- a/freemarker-core/src/main/javacc/freemarker/core/FTL.jj
+++ b/freemarker-core/src/main/javacc/freemarker/core/FTL.jj
@@ -944,7 +944,7 @@ TOKEN:
     <ITEMS : <START_TAG> "items" (<BLANK>)+ <AS> <BLANK>> { 
handleTagSyntaxAndSwitch(matchedToken, FM_EXPRESSION); }
     |
     <SEP : <START_TAG> "sep" <CLOSE_TAG1>> {
-        if (incompatibleImprovements >= _VersionInts.V_2_3_24) 
handleTagSyntaxAndSwitch(matchedToken, DEFAULT);
+        if (incompatibleImprovements >= _VersionInts.V_2_3_34) 
handleTagSyntaxAndSwitch(matchedToken, DEFAULT);
     }
     |
     <FOREACH : <START_TAG> "for" ("e" | "E") "ach" <BLANK>> {
diff --git 
a/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java 
b/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java
index 3e835d76..f842c059 100644
--- a/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java
+++ b/freemarker-core/src/test/java/freemarker/core/SepParsingBugTest.java
@@ -31,23 +31,27 @@ public class SepParsingBugTest extends TemplateTest {
     
     @Test
     public void testAutodetectTagSyntax() throws TemplateException, 
IOException {
-        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24);
+        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_34);
         getConfiguration().setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX);
         assertOutput("<#list [1, 2] as i>${i}<#sep>, </#list>", "1, 2");
         assertOutput("[#list [1, 2] as i]${i}[#sep], [/#list]", "1, 2");
         assertOutput("<#list [1, 2] as i>${i}[#sep], </#list>", "1[#sep], 
2[#sep], ");
         assertOutput("[#list [1, 2] as i]${i}<#sep>, [/#list]", "1<#sep>, 
2<#sep>, ");
+        assertOutput("[#list [1, 2] as i]${i}[sep], [/#list]", "1[sep], 
2[sep], ");
+        assertOutput("[#list [1, 2] as i]${i}<sep>, [/#list]", "1<sep>, 
2<sep>, ");
         assertErrorContains("<#sep>", "#sep must be inside");
         assertErrorContains("[#sep]", "#sep must be inside");
     }
 
     @Test
     public void testAngleBracketsTagSyntax() throws TemplateException, 
IOException {
-        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24);
+        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_34);
         
getConfiguration().setTagSyntax(Configuration.ANGLE_BRACKET_TAG_SYNTAX);
         assertOutput("<#list [1, 2] as i>${i}<#sep>, </#list>", "1, 2");
         assertOutput("[#list [1, 2] as i]${i!'-'}[#sep], [/#list]", "[#list 
[1, 2] as i]-[#sep], [/#list]");
         assertOutput("<#list [1, 2] as i>${i}[#sep], </#list>", "1[#sep], 
2[#sep], ");
+        assertOutput("<#list [1, 2] as i>${i}<sep>, </#list>", "1<sep>, 
2<sep>, ");
+        assertOutput("<#list [1, 2] as i>${i}[sep], </#list>", "1[sep], 
2[sep], ");
         assertErrorContains("[#list [1, 2] as i]${i}<#sep>, [/#list]", "#sep 
must be inside");
         assertErrorContains("<#sep>", "#sep must be inside");
         assertOutput("[#sep]", "[#sep]");
@@ -55,20 +59,26 @@ public class SepParsingBugTest extends TemplateTest {
 
     @Test
     public void testSquareBracketTagSyntax() throws TemplateException, 
IOException {
-        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_24);
+        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_34);
         
getConfiguration().setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX);
         assertOutput("<#list [1, 2] as i>${i!'-'}<#sep>, </#list>", "<#list 
[1, 2] as i>-<#sep>, </#list>");
         assertOutput("[#list [1, 2] as i]${i}[#sep], [/#list]", "1, 2");
         assertErrorContains("<#list [1, 2] as i>${i}[#sep], </#list>", "#sep 
must be inside");
         assertOutput("[#list [1, 2] as i]${i}<#sep>, [/#list]", "1<#sep>, 
2<#sep>, ");
+        assertOutput("[#list [1, 2] as i]${i}[sep], [/#list]", "1[sep], 
2[sep], ");
+        assertOutput("[#list [1, 2] as i]${i}<sep>, [/#list]", "1<sep>, 
2<sep>, ");
         assertOutput("<#sep>", "<#sep>");
         assertErrorContains("[#sep]", "#sep must be inside");
     }
 
     @Test
-    public void testLegacyTagSyntax() throws TemplateException, IOException {
-        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_23);
+    public void testPre2Dot3Dot34BugRecreated() throws TemplateException, 
IOException {
+        
getConfiguration().setIncompatibleImprovements(Configuration.VERSION_2_3_33);
         getConfiguration().setTagSyntax(Configuration.AUTO_DETECT_TAG_SYNTAX);
         assertOutput("<#list [1, 2] as i>${i}<sep>, </#list>", "1, 2");
+        assertOutput("<#list [1, 2] as i>${i}[#sep], </#list>", "1, 2");
+        // square bracket tags were always "strict":
+        assertOutput("[#list [1, 2] as i]${i}[sep], [/#list]", "1[sep], 
2[sep], ");
+        assertOutput("[#list [1, 2] as i]${i}<#sep>, [/#list]", "1, 2");
     }
 }
diff --git a/freemarker-manual/src/main/docgen/en_US/book.xml 
b/freemarker-manual/src/main/docgen/en_US/book.xml
index 3bc229e6..08ca6b68 100644
--- a/freemarker-manual/src/main/docgen/en_US/book.xml
+++ b/freemarker-manual/src/main/docgen/en_US/book.xml
@@ -30458,7 +30458,7 @@ TemplateModel x = env.getVariable("x");  // get 
variable x</programlisting>
       <section xml:id="versions_2_3_34">
         <title>2.3.34</title>
 
-        <para>Release date: 2024-12-01 + release process</para>
+        <para>Release date: 2024-12-08 + release process</para>
 
         <section>
           <title>Changes on the FTL side</title>
@@ -30501,13 +30501,19 @@ TemplateModel x = env.getVariable("x");  // get 
variable x</programlisting>
             <listitem>
               <para><link
               xlink:href="https://github.com/apache/freemarker/pull/119";>GitHub
-              PR-119</link>: Fixed bug: Both <literal>[#sep]</literal> and
-              <literal>&lt;#sep&gt;</literal> were interpreted as a call to
+              PR-119</link>: Fixed bug if you set the <link
+              
linkend="pgui_config_incompatible_improvements_how_to_set"><literal>incompatible_improvements</literal>
+              setting</link> to 2.3.34 or higher: Both
+              <literal>[#sep]</literal>, <literal>&lt;#sep&gt;</literal>, and
+              <literal>&lt;sep&gt;</literal> were all interpreted as a call to
               the <literal>sep</literal> directive, regardless if the already
-              established tag syntax was angle bracket or square bracket tags.
-              For now on, the tag will be seen as just static text, if the
-              opposite tag syntax was already established, just as it's done
-              for all other FTL tags.</para>
+              established tag syntax was angle bracket or square bracket tags,
+              or if the tag syntax was <quote>strict</quote> (requiring
+              <literal>#</literal>) or not. With this fix enabled via
+              <literal>incompatible_improvements</literal>, a
+              <literal>sep</literal> with the tag syntax that doesn't match
+              the configured/estabilished tag syntax will be seen as just
+              static text, just as it's done for any other FTL tags.</para>
             </listitem>
 
             <listitem>

Reply via email to