Author: markt
Date: Fri Oct 24 23:27:40 2014
New Revision: 1634161

URL: http://svn.apache.org/r1634161
Log:
Follow up to r1634089.
Fix some additional test failures with the stricter escaping rules.

Modified:
    tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java
    tomcat/trunk/java/org/apache/jasper/compiler/Parser.java
    tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java

Modified: tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java?rev=1634161&r1=1634160&r2=1634161&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java Fri Oct 24 
23:27:40 2014
@@ -244,13 +244,15 @@ public class ELParser {
         for (int i = 0; i < len; i++) {
             char ch = input.charAt(i);
             if (ch =='$' || (!isDeferredSyntaxAllowedAsLiteral && ch == '#')) {
-                if (output == null) {
-                    output = new StringBuilder(len + 20);
+                if (i + 1 < len && input.charAt(i + 1) == '{') {
+                    if (output == null) {
+                        output = new StringBuilder(len + 20);
+                    }
+                    output.append(input.substring(lastAppend, i));
+                    lastAppend = i + 1;
+                    output.append('\\');
+                    output.append(ch);
                 }
-                output.append(input.substring(lastAppend, i));
-                lastAppend = i + 1;
-                output.append('\\');
-                output.append(ch);
             }
         }
         if (output == null) {

Modified: tomcat/trunk/java/org/apache/jasper/compiler/Parser.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1634161&r1=1634160&r2=1634161&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/compiler/Parser.java (original)
+++ tomcat/trunk/java/org/apache/jasper/compiler/Parser.java Fri Oct 24 
23:27:40 2014
@@ -1283,16 +1283,9 @@ class Parser implements TagConstants {
             return;
 
         CharArrayWriter ttext = new CharArrayWriter();
-        // Output the first character
-        int ch = reader.nextChar();
-        if (ch == '\\') {
-            reader.pushChar();
-        } else {
-            ttext.write(ch);
-        }
 
         while (reader.hasMoreInput()) {
-            ch = reader.nextChar();
+            int ch = reader.nextChar();
             if (ch == '<') {
                 // Check for "<\%"
                 if (reader.nextChar() == '\\') {
@@ -1302,13 +1295,21 @@ class Parser implements TagConstants {
                     } else {
                         reader.pushChar();
                         reader.pushChar();
-                        reader.pushChar();
-                        break;
+                        if (ttext.size() == 0) {
+                            ttext.append('<');
+                        } else {
+                            reader.pushChar();
+                            break;
+                        }
                     }
                 } else {
                     reader.pushChar();
-                    reader.pushChar();
-                    break;
+                    if (ttext.size() == 0) {
+                        ttext.append('<');
+                    } else {
+                        reader.pushChar();
+                        break;
+                    }
                 }
             } else if (ch == '\\' && !pageInfo.isELIgnored()) {
                 int next = reader.nextChar();
@@ -1325,7 +1326,8 @@ class Parser implements TagConstants {
                     ttext.append('\\');
                     reader.pushChar();
                 }
-            } else if ((ch == '$' || ch == '#') && !pageInfo.isELIgnored()) {
+            } else if ((ch == '$' || ch == '#' && 
!pageInfo.isDeferredSyntaxAllowedAsLiteral()) &&
+                    !pageInfo.isELIgnored()) {
                 if (reader.nextChar() == '{') {
                     reader.pushChar();
                     reader.pushChar();

Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java?rev=1634161&r1=1634160&r2=1634161&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java Fri Oct 24 
23:27:40 2014
@@ -412,9 +412,9 @@ public class TestParser extends TomcatBa
         Assert.assertTrue(result, result.contains("<set 
data-value=\"03b\\\\x\\?resize03b\"/>"));
         Assert.assertTrue(result, result.contains("<04a\\?resize04a/>"));
         Assert.assertTrue(result, result.contains("<04b\\\\x\\?resize04b/>"));
-        Assert.assertTrue(result, result.contains("<set 
data-value=\"05a$${&amp;\"/>"));
-        Assert.assertTrue(result, result.contains("<set 
data-value=\"05b$${&amp;2\"/>"));
-        Assert.assertTrue(result, result.contains("<set 
data-value=\"05c##{&gt;hello&lt;\"/>"));
+        Assert.assertTrue(result, result.contains("<set 
data-value=\"05a\\$${&amp;\"/>"));
+        Assert.assertTrue(result, result.contains("<set 
data-value=\"05b\\$${&amp;2\"/>"));
+        Assert.assertTrue(result, result.contains("<set 
data-value=\"05c\\##{&gt;hello&lt;\"/>"));
         Assert.assertTrue(result, result.contains("05x:<set 
data-value=\"\"/>"));
         Assert.assertTrue(result, result.contains("<set 
xmlns:foo=\"urn:06a\\bar\\baz\"/>"));
         Assert.assertTrue(result, result.contains("07a:<set 
data-value=\"\\?resize\"/>"));



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to