velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cbris...@apache.org
Subject svn commit: r1032135 - in /velocity/engine/branches/2.0_Exp/velocity-engine-core/src: main/java/ main/java/org/apache/velocity/runtime/directive/ main/java/org/apache/velocity/runtime/parser/node/ test/java/ test/java/org/apache/velocity/test/issues/
Date Sat, 06 Nov 2010 20:33:17 GMT
Author: cbrisson
Date: Sat Nov  6 20:33:17 2010
New Revision: 1032135

URL: http://svn.apache.org/viewvc?rev=1032135&view=rev
Log:
merge Jarkko patch from trunk into engine-2.x for VELOCITY-785

Added:
    velocity/engine/branches/2.0_Exp/velocity-engine-core/src/test/java/org/apache/velocity/test/issues/Velocity785TestCase.java
      - copied unchanged from r1032134, velocity/engine/trunk/src/test/org/apache/velocity/test/issues/Velocity785TestCase.java
Modified:
    velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/   (props changed)
    velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Stop.java
  (props changed)
    velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
    velocity/engine/branches/2.0_Exp/velocity-engine-core/src/test/java/   (props changed)

Propchange: velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov  6 20:33:17 2010
@@ -1,2 +1,3 @@
 /velocity/engine/branches/2.0_Exp/src/java:958513,991637-995742
 /velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java:958513
+/velocity/engine/trunk/src/java:1032134

Propchange: velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/directive/Stop.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov  6 20:33:17 2010
@@ -1 +1,2 @@
 /velocity/engine/branches/2.0_Exp/src/java/org/apache/velocity/runtime/directive/Stop.java:958513
+/velocity/engine/trunk/src/java/org/apache/velocity/runtime/directive/Stop.java:1032134

Modified: velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
URL: http://svn.apache.org/viewvc/velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java?rev=1032135&r1=1032134&r2=1032135&view=diff
==============================================================================
--- velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
(original)
+++ velocity/engine/branches/2.0_Exp/velocity-engine-core/src/main/java/org/apache/velocity/runtime/parser/node/ASTStringLiteral.java
Sat Nov  6 20:33:17 2010
@@ -118,7 +118,7 @@ public class ASTStringLiteral extends Si
         {
             // replace double-double quotes like "" with a single double quote "
             // replace double single quotes '' with a single quote '
-            image = replaceQuotes(image);
+            image = replaceQuotes(image, img.charAt(0));
         }
 
         /**
@@ -219,15 +219,21 @@ public class ASTStringLiteral extends Si
     }
 
     /**
-     * Replaces double double-quotes with a single double quote ("" to ")
-     * Replaces double single quotes with a single quote ('' to ')
+     * Replaces double double-quotes with a single double quote ("" to ").
+     * Replaces double single quotes with a single quote ('' to ').
+	 *
+	 * @param s StringLiteral without the surrounding quotes
+	 * @param literalQuoteChar char that starts the StringLiteral (" or ')
      */     
-    private String replaceQuotes(String s)
+    private String replaceQuotes(String s, char literalQuoteChar)
     {
-        if( s.indexOf("\"") == -1 && s.indexOf("'") == -1 )
+        if( (literalQuoteChar == '"' && s.indexOf("\"") == -1) ||
+            (literalQuoteChar == '\'' && s.indexOf("'") == -1) )
+        {
             return s;
+        }
     
-        StrBuilder result = new StrBuilder();
+        StrBuilder result = new StrBuilder(s.length());
         char prev = ' ';
         for(int i = 0, is = s.length(); i < is; i++)
         {
@@ -237,7 +243,11 @@ public class ASTStringLiteral extends Si
             if( i + 1 < is )
             {
                 char next =  s.charAt(i + 1);
-                if( (next == '"' && c == '"') || (next == '\'' && c == '\'')
)
+				// '""' -> "", "''" -> '' 
+				// thus it is not necessary to double quotes if the "surrounding" quotes
+				// of the StringLiteral are different. See VELOCITY-785
+                if( (literalQuoteChar == '"' && (next == '"' && c == '"'))
|| 
+				    (literalQuoteChar == '\'' && (next == '\'' && c == '\'')) )
                 {
                     i++;
                 }

Propchange: velocity/engine/branches/2.0_Exp/velocity-engine-core/src/test/java/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov  6 20:33:17 2010
@@ -1,3 +1,4 @@
 /velocity/engine/branches/2.0_Exp/src/test:991639-992140
 /velocity/engine/branches/2.0_Exp/velocity-engine-core/src/test/java:958513,991637-995742
+/velocity/engine/trunk/src/test:1032134
 /velocity/engine/trunk/velocity-engine-core/src/test/java:992133



Mime
View raw message