On 10/09/2015 14:20, Mark Thomas wrote:
> On 10/09/2015 14:18, ma...@apache.org wrote:
>> Author: markt
>> Date: Thu Sep 10 13:18:02 2015
>> New Revision: 1702244
>>
>> URL: http://svn.apache.org/r1702244
> 
> Reviews particularly welcome for this commit since it changes a number
> of EL in JSP edge cases.
> 
> The intention is to better adhere to the specs.
> 
> I'll give it a couple of days before back-porting this to give folks a
> chance to look at it and comment.

Ping (in case this got drowned in the flood of data race fixes).

My current plan is to back-port this to 8.0.x in time for the next
release. I'll leave this until last to give folks as much opportunity to
review the patch. If there are objections, I'm happy to delay the
back-port while we discuss the objections.

Mark


> 
> Mark
> 
> 
>> Log:
>> For EL expressions used within attribute values:
>> a) attribute escaping (e.g. for quotes) DOES NOT apply inside the EL 
>> expression
>> b) EL expressions can not be used with scriptlets (<%= ... %>)
>>
>> For EL expressions in JSP
>> c) '\$' is an escape for '$' rather than '\${' being an escape for '${'
>> d) '\#' is an escape for '#' rather than '\#{' being an escape for '#{'
>>
>> The implications of this include:
>> 1. Due to a) 
>>    <tags:echo echo="10-${'hello "world'}" />
>>    is treated as valid (previously the double quote had to be escaped)
>>
>> 2. Due to c) (and similarly for d))
>>    <p>04-\$500</p>
>>    will now render as
>>    <p>04-$500</p>
>>    whereas previously it rendered unchanged
>>
>> 3. Due to a)
>>    <tags:echo echo="01-${\"hello world\"}" />
>>    will now trigger an error
>>
>> Modified:
>>     tomcat/trunk/java/org/apache/jasper/compiler/AttributeParser.java
>>     tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java
>>     tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
>>     tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java
>>     tomcat/trunk/java/org/apache/jasper/compiler/Parser.java
>>     tomcat/trunk/test/org/apache/el/TestELInJsp.java
>>     tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java
>>     tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java
>>     tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java
>>     tomcat/trunk/test/webapp/bug45nnn/bug45427.jsp
>>     tomcat/trunk/test/webapp/bug45nnn/bug45451.jspf
>>     tomcat/trunk/test/webapp/bug45nnn/bug45451a.jsp
>>     tomcat/trunk/test/webapp/el-method.jsp
>>     tomcat/trunk/test/webapp/el-misc.jsp
>>
>> Modified: tomcat/trunk/java/org/apache/jasper/compiler/AttributeParser.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/AttributeParser.java?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/compiler/AttributeParser.java 
>> (original)
>> +++ tomcat/trunk/java/org/apache/jasper/compiler/AttributeParser.java Thu 
>> Sep 10 13:18:02 2015
>> @@ -202,11 +202,11 @@ public class AttributeParser {
>>      }
>>  
>>      /*
>> -     * For EL need to unquote everything but no need to convert anything. 
>> The
>> -     * EL is terminated by '}'. The only other valid location for '}' is 
>> inside
>> -     * a StringLiteral. The literals are delimited by '\'' or '\"'. The only
>> -     * other valid location for '\'' or '\"' is also inside a 
>> StringLiteral. A
>> -     * quote character inside a StringLiteral must be escaped if the same 
>> quote
>> +     * Once inside EL, no need to unquote or convert anything. The EL is
>> +     * terminated by '}'. The only other valid location for '}' is inside a
>> +     * StringLiteral. The literals are delimited by '\'' or '\"'. The only 
>> other
>> +     * valid location for '\'' or '\"' is also inside a StringLiteral. A 
>> quote
>> +     * character inside a StringLiteral must be escaped if the same quote
>>       * character is used to delimit the StringLiteral.
>>       */
>>      private void parseEL() {
>> @@ -214,7 +214,7 @@ public class AttributeParser {
>>          boolean insideLiteral = false;
>>          char literalQuote = 0;
>>          while (i < size && !endEL) {
>> -            char ch = nextChar();
>> +            char ch = input.charAt(i++);
>>              if (ch == '\'' || ch == '\"') {
>>                  if (insideLiteral) {
>>                      if (literalQuote == ch) {
>> @@ -228,7 +228,7 @@ public class AttributeParser {
>>              } else if (ch == '\\') {
>>                  result.append(ch);
>>                  if (insideLiteral && size < i) {
>> -                    ch = nextChar();
>> +                    ch = input.charAt(i++);
>>                      result.append(ch);
>>                  }
>>              } else if (ch == '}') {
>>
>> 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=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java (original)
>> +++ tomcat/trunk/java/org/apache/jasper/compiler/ELParser.java Thu Sep 10 
>> 13:18:02 2015
>> @@ -205,11 +205,9 @@ public class ELParser {
>>          while (hasNextChar()) {
>>              char ch = nextChar();
>>              if (ch == '\\') {
>> -                // Is this the start of a "\${" or "\#{" escape sequence?
>> +                // Is this the start of a "\$" or "\#" escape sequence?
>>                  char p0 = peek(0);
>> -                char p1 = peek(1);
>> -                if ((p0 == '$' || (p0 == '#' && 
>> !isDeferredSyntaxAllowedAsLiteral)) && p1 == '{') {
>> -                    buf.append(nextChar());
>> +                if (p0 == '$' || (p0 == '#' && 
>> !isDeferredSyntaxAllowedAsLiteral)) {
>>                      buf.append(nextChar());
>>                  } else {
>>                      buf.append(ch);
>> @@ -229,7 +227,8 @@ public class ELParser {
>>  
>>      /**
>>       * Escape '$' and '#', inverting the unescaping performed in
>> -     * {@link #skipUntilEL()}.
>> +     * {@link #skipUntilEL()} but only for ${ and #{ sequences since 
>> escaping
>> +     * for $ and # is optional.
>>       *
>>       * @param input Non-EL input to be escaped
>>       * @param isDeferredSyntaxAllowedAsLiteral
>>
>> Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java 
>> (original)
>> +++ tomcat/trunk/java/org/apache/jasper/compiler/JspDocumentParser.java Thu 
>> Sep 10 13:18:02 2015
>> @@ -605,11 +605,7 @@ class JspDocumentParser
>>                          lastCh = ch;
>>                      }
>>                  } else if (lastCh == '\\' && (ch == '$' || ch == '#')) {
>> -                    if (i + 1 < charBuffer.length() && charBuffer.charAt(i 
>> + 1) == '{') {
>> -                        if (pageInfo.isELIgnored()) {
>> -                            ttext.write('\\');
>> -                        }
>> -                    } else {
>> +                    if (pageInfo.isELIgnored()) {
>>                          ttext.write('\\');
>>                      }
>>                      ttext.write(ch);
>>
>> Modified: tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java (original)
>> +++ tomcat/trunk/java/org/apache/jasper/compiler/JspReader.java Thu Sep 10 
>> 13:18:02 2015
>> @@ -436,15 +436,17 @@ class JspReader {
>>  
>>      /**
>>       * Skip until the given string is matched in the stream, but ignoring
>> -     * chars initially escaped by a '\'.
>> +     * chars initially escaped by a '\' and any EL expressions.
>>       * When returned, the context is positioned past the end of the match.
>>       *
>>       * @param s The String to match.
>> +     * @param ignoreEL <code>true</code> if something that looks like EL 
>> should
>> +     *                 not be treated as EL.
>>       * @return A non-null <code>Mark</code> instance (positioned immediately
>>       *         before the search string) if found, <strong>null</strong>
>>       *         otherwise.
>>       */
>> -    Mark skipUntilIgnoreEsc(String limit) {
>> +    Mark skipUntilIgnoreEsc(String limit, boolean ignoreEL) {
>>          Mark ret = mark();
>>          int limlen = limit.length();
>>          int ch;
>> @@ -454,6 +456,12 @@ class JspReader {
>>          for (ch = nextChar(ret) ; ch != -1 ; prev = ch, ch = nextChar(ret)) 
>> {
>>              if (ch == '\\' && prev == '\\') {
>>                  ch = 0;                // Double \ is not an escape char 
>> anymore
>> +            } else if (prev == '\\') {
>> +                continue;
>> +            } else if (!ignoreEL && (ch == '$' || ch == '#') && peekChar() 
>> == '{' ) {
>> +                // Move beyond the '{'
>> +                nextChar();
>> +                skipELExpression();
>>              } else if (ch == firstChar && prev != '\\') {
>>                  for (int i = 1 ; i < limlen ; i++) {
>>                      if (peekChar() == limit.charAt(i))
>>
>> 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=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/java/org/apache/jasper/compiler/Parser.java (original)
>> +++ tomcat/trunk/java/org/apache/jasper/compiler/Parser.java Thu Sep 10 
>> 13:18:02 2015
>> @@ -199,6 +199,8 @@ class Parser implements TagConstants {
>>          if (qName == null)
>>              return false;
>>  
>> +        boolean ignoreEL = pageInfo.isELIgnored();
>> +
>>          // Determine prefix and local name components
>>          String localName = qName;
>>          String uri = "";
>> @@ -223,11 +225,14 @@ class Parser implements TagConstants {
>>              err.jspError(reader.mark(), "jsp.error.attribute.noquote");
>>  
>>          String watchString = "";
>> -        if (reader.matches("<%="))
>> +        if (reader.matches("<%=")) {
>>              watchString = "%>";
>> +            // Can't embed EL in a script expression
>> +            ignoreEL = true;
>> +        }
>>          watchString = watchString + quote;
>>  
>> -        String attrValue = parseAttributeValue(watchString);
>> +        String attrValue = parseAttributeValue(watchString, ignoreEL);
>>          attrs.addAttribute(uri, localName, qName, "CDATA", attrValue);
>>          return true;
>>      }
>> @@ -258,9 +263,9 @@ class Parser implements TagConstants {
>>       * RTAttributeValueDouble ::= ((QuotedChar - '"')* - 
>> ((QuotedChar-'"')'%>"')
>>       * ('%>"' | TRANSLATION_ERROR)
>>       */
>> -    private String parseAttributeValue(String watch) throws JasperException 
>> {
>> +    private String parseAttributeValue(String watch, boolean ignoreEL) 
>> throws JasperException {
>>          Mark start = reader.mark();
>> -        Mark stop = reader.skipUntilIgnoreEsc(watch);
>> +        Mark stop = reader.skipUntilIgnoreEsc(watch, ignoreEL);
>>          if (stop == null) {
>>              err.jspError(start, "jsp.error.attribute.unterminated", watch);
>>          }
>> @@ -1275,7 +1280,11 @@ class Parser implements TagConstants {
>>  
>>      /*
>>       * Parse for a template text string until '<' or "${" or "#{" is 
>> encountered,
>> -     * recognizing escape sequences "<\%", "\${", and "\#{".
>> +     * recognizing escape sequences "<\%", "\$", and "\#".
>> +     *
>> +     * Note: JSP uses '\$' as an escape for '$' and '\#' for '#' whereas EL 
>> uses
>> +     *       '\${' for '${' and '\#{' for '#{'. We are processing JSP 
>> template
>> +     *       test here so the JSP escapes apply.
>>       */
>>      private void parseTemplateText(Node parent) {
>>  
>> @@ -1304,13 +1313,7 @@ class Parser implements TagConstants {
>>              } else if (ch == '\\' && !pageInfo.isELIgnored()) {
>>                  int next = reader.peekChar(0);
>>                  if (next == '$' || next == '#') {
>> -                    if (reader.peekChar(1) == '{') {
>> -                        ttext.write(reader.nextChar());
>> -                        ttext.write(reader.nextChar());
>> -                    } else {
>> -                        ttext.write(ch);
>> -                        ttext.write(reader.nextChar());
>> -                    }
>> +                    ttext.write(reader.nextChar());
>>                  } else {
>>                      ttext.write(ch);
>>                  }
>> @@ -1362,10 +1365,7 @@ class Parser implements TagConstants {
>>                  } else if (ch == '\\') {
>>                      int next = reader.peekChar(0);
>>                      if (next == '$' || next =='#') {
>> -                        if (reader.peekChar(1) == '{') {
>> -                            ttext.write(reader.nextChar());
>> -                            ttext.write(reader.nextChar());
>> -                        }
>> +                        ttext.write(reader.nextChar());
>>                      } else {
>>                          ttext.write('\\');
>>                      }
>>
>> Modified: tomcat/trunk/test/org/apache/el/TestELInJsp.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/el/TestELInJsp.java?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/org/apache/el/TestELInJsp.java (original)
>> +++ tomcat/trunk/test/org/apache/el/TestELInJsp.java Thu Sep 10 13:18:02 2015
>> @@ -93,21 +93,19 @@ public class TestELInJsp extends TomcatB
>>          assertEcho(result, "00-hello world");
>>          assertEcho(result, "01-hello 'world");
>>          assertEcho(result, "02-hello \"world");
>> -        assertEcho(result, "03-hello world");
>> -        assertEcho(result, "04-hello 'world");
>> -        assertEcho(result, "05-hello \"world");
>> -        assertEcho(result, "06-hello world");
>> -        assertEcho(result, "07-hello 'world");
>> -        assertEcho(result, "08-hello \"world");
>> -        assertEcho(result, "09-hello world");
>> -        assertEcho(result, "10-hello 'world");
>> +        assertEcho(result, "03-hello \"world");
>> +        assertEcho(result, "04-hello world");
>> +        assertEcho(result, "05-hello 'world");
>> +        assertEcho(result, "06-hello 'world");
>> +        assertEcho(result, "07-hello \"world");
>> +        assertEcho(result, "08-hello world");
>> +        assertEcho(result, "09-hello 'world");
>> +        assertEcho(result, "10-hello \"world");
>>          assertEcho(result, "11-hello \"world");
>>          assertEcho(result, "12-hello world");
>>          assertEcho(result, "13-hello 'world");
>> -        assertEcho(result, "14-hello \"world");
>> -        assertEcho(result, "15-hello world");
>> -        assertEcho(result, "16-hello 'world");
>> -        assertEcho(result, "17-hello \"world");
>> +        assertEcho(result, "14-hello 'world");
>> +        assertEcho(result, "15-hello \"world");
>>      }
>>  
>>      @Test
>> @@ -121,8 +119,6 @@ public class TestELInJsp extends TomcatB
>>          // Warning: JSP attribute escaping != Java String escaping
>>          assertEcho(result, "00-\\'hello world\\'");
>>          assertEcho(result, "01-\\'hello world\\'");
>> -        assertEcho(result, "02-\\'hello world\\'");
>> -        assertEcho(result, "03-\\'hello world\\'");
>>  
>>          res = getUrl("http://localhost:"; + getPort() + 
>> "/test/bug45nnn/bug45451b.jsp");
>>          result = res.toString();
>> @@ -133,18 +129,25 @@ public class TestELInJsp extends TomcatB
>>          assertEcho(result, "01-${1+1}");
>>          assertEcho(result, "02-\\${1+1}");
>>          assertEcho(result, "03-\\\\${1+1}");
>> -        assertEcho(result, "04-\\$500");
>> +        assertEcho(result, "04-$500");
>> +        // Inside an EL literal '\' is only used to escape '\', ''' and '"'
>> +        assertEcho(result, "05-\\$");
>> +        assertEcho(result, "06-\\${");
>>          assertEcho(result, "10-2");
>>          assertEcho(result, "11-${1+1}");
>>          assertEcho(result, "12-\\2");
>>          assertEcho(result, "13-\\${1+1}");
>>          assertEcho(result, "14-\\\\2");
>> -        assertEcho(result, "15-\\$500");
>> +        assertEcho(result, "15-$500");
>> +        assertEcho(result, "16-\\$");
>> +        assertEcho(result, "17-\\${");
>>          assertEcho(result, "20-2");
>>          assertEcho(result, "21-#{1+1}");
>>          assertEcho(result, "22-\\2");
>>          assertEcho(result, "23-\\#{1+1}");
>>          assertEcho(result, "24-\\\\2");
>> +        assertEcho(result, "25-\\#");
>> +        assertEcho(result, "26-\\#{");
>>  
>>          res = getUrl("http://localhost:"; + getPort() + 
>> "/test/bug45nnn/bug45451c.jsp");
>>          result = res.toString();
>> @@ -176,13 +179,13 @@ public class TestELInJsp extends TomcatB
>>          assertEcho(result, "01-${1+1}");
>>          assertEcho(result, "02-\\${1+1}");
>>          assertEcho(result, "03-\\\\${1+1}");
>> -        assertEcho(result, "04-\\$500");
>> +        assertEcho(result, "04-$500");
>>          assertEcho(result, "10-2");
>>          assertEcho(result, "11-${1+1}");
>>          assertEcho(result, "12-\\${1+1}");
>>          assertEcho(result, "13-\\\\${1+1}");
>>          assertEcho(result, "14-\\\\\\${1+1}");
>> -        assertEcho(result, "15-\\$500");
>> +        assertEcho(result, "15-$500");
>>          assertEcho(result, "20-2");
>>          assertEcho(result, "21-#{1+1}");
>>          assertEcho(result, "22-\\#{1+1}");
>> @@ -198,13 +201,13 @@ public class TestELInJsp extends TomcatB
>>          assertEcho(result, "01-${1+1}");
>>          assertEcho(result, "02-\\${1+1}");
>>          assertEcho(result, "03-\\\\${1+1}");
>> -        assertEcho(result, "04-\\$500");
>> +        assertEcho(result, "04-$500");
>>          assertEcho(result, "10-2");
>>          assertEcho(result, "11-${1+1}");
>>          assertEcho(result, "12-\\2");
>>          assertEcho(result, "13-\\${1+1}");
>>          assertEcho(result, "14-\\\\2");
>> -        assertEcho(result, "15-\\$500");
>> +        assertEcho(result, "15-$500");
>>          assertEcho(result, "20-#{1+1}");
>>          assertEcho(result, "21-\\#{1+1}");
>>          assertEcho(result, "22-\\#{1+1}");
>> @@ -303,13 +306,13 @@ public class TestELInJsp extends TomcatB
>>          assertEcho(result, "08-a2z");
>>          assertEcho(result, "09-az2");
>>          assertEcho(result, "10-${'foo'}bar");
>> -        assertEcho(result, "11-\"}");
>> +        assertEcho(result, "11-\\\"}");
>>          assertEcho(result, "12-foo\\bar\\baz");
>>          assertEcho(result, "13-foo\\bar\\baz");
>>          assertEcho(result, "14-foo\\bar\\baz");
>>          assertEcho(result, "15-foo\\bar\\baz");
>>          assertEcho(result, "16-foo\\bar\\baz");
>> -        assertEcho(result, "17-foo\\bar\\baz");
>> +        assertEcho(result, "17-foo\\&apos;bar&apos;\\&quot;baz&quot;");
>>          assertEcho(result, "18-3");
>>          assertEcho(result, "19-4");
>>          assertEcho(result, "20-4");
>>
>> Modified: 
>> tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java 
>> (original)
>> +++ tomcat/trunk/test/org/apache/jasper/compiler/TestAttributeParser.java 
>> Thu Sep 10 13:18:02 2015
>> @@ -127,19 +127,15 @@ public class TestAttributeParser {
>>          // list and looking at the spec to find some edge cases
>>  
>>          // '\' is only an escape character inside a StringLiteral
>> -        assertEquals("\\", evalAttr("${'\\\\\\\\'}", '\"'));
>> -        assertEquals("\\", evalAttr("${\"\\\\\\\\\"}", '\"'));
>> +        // Attribute escaping does not apply inside EL expressions
>> +        assertEquals("\\", evalAttr("${'\\\\'}", '\"'));
>>  
>>          // Can use ''' inside '"' when quoting with '"' and vice versa 
>> without
>>          // escaping
>> -        assertEquals("\\\"", evalAttr("${'\\\\\\\\\\\"'}", '\"'));
>> -        assertEquals("\"\\", evalAttr("${'\\\"\\\\\\\\'}", '\"'));
>> -        assertEquals("\\'", evalAttr("${'\\\\\\\\\\\\''}", '\"'));
>> -        assertEquals("'\\", evalAttr("${'\\\\'\\\\\\\\'}", '\"'));
>> -        assertEquals("\\'", evalAttr("${\\\"\\\\\\\\'\\\"}", '\"'));
>> -        assertEquals("'\\", evalAttr("${\\\"'\\\\\\\\\\\"}", '\"'));
>> -        assertEquals("\\\"", evalAttr("${\\\"\\\\\\\\\\\\\\\"\\\"}", '\"'));
>> -        assertEquals("\"\\", evalAttr("${\\\"\\\\\\\"\\\\\\\\\\\"}", '\"'));
>> +        assertEquals("\\\"", evalAttr("${'\\\\\"'}", '\"'));
>> +        assertEquals("\"\\", evalAttr("${'\\\"\\\\'}", '\"'));
>> +        assertEquals("\\'", evalAttr("${'\\\\\\''}", '\"'));
>> +        assertEquals("'\\", evalAttr("${'\\'\\\\'}", '\"'));
>>  
>>          // Quoting <% and %>
>>          assertEquals("hello <% world", evalAttr("hello <\\% world", '\"'));
>> @@ -156,9 +152,8 @@ public class TestAttributeParser {
>>          // expression that follows from being evaluated.
>>          //
>>          assertEquals("foo\\bar\\baz", 
>> evalAttr("${\'foo\'}\\\\${\'bar\'}\\\\${\'baz\'}", '\"'));
>> -        assertEquals("foo\\bar\\baz", 
>> evalAttr("${\'foo\'}\\\\${\\\"bar\\\"}\\\\${\'baz\'}", '\"'));
>> -        assertEquals("foo\\bar\\baz", 
>> evalAttr("${\\\"foo\\\"}\\\\${\'bar\'}\\\\${\\\"baz\\\"}", '\"'));
>> -        assertEquals("foo\\bar\\baz", 
>> evalAttr("${\"foo\"}\\\\${\\\'bar\\\'}\\\\${\"baz\"}", '\''));
>> +        assertEquals("foo\\bar\\baz", 
>> evalAttr("${\'foo\'}\\\\${\"bar\"}\\\\${\'baz\'}", '\"'));
>> +        assertEquals("foo\\bar\\baz", 
>> evalAttr("${\"foo\"}\\\\${\'bar\'}\\\\${\"baz\"}", '\"'));
>>      }
>>  
>>      @Test
>>
>> Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java (original)
>> +++ tomcat/trunk/test/org/apache/jasper/compiler/TestELParser.java Thu Sep 
>> 10 13:18:02 2015
>> @@ -238,13 +238,15 @@ public class TestELParser {
>>  
>>      @Test
>>      public void testEscape04() throws JasperException {
>> -        doTestParser("\\$", "\\$");
>> +        // When parsed as EL in JSP the escaping of $ as \$ is optional
>> +        doTestParser("\\$", "\\$", "$");
>>      }
>>  
>>  
>>      @Test
>>      public void testEscape05() throws JasperException {
>> -        doTestParser("\\#", "\\#");
>> +        // When parsed as EL in JSP the escaping of # as \# is optional
>> +        doTestParser("\\#", "\\#", "#");
>>      }
>>  
>>  
>> @@ -280,18 +282,23 @@ public class TestELParser {
>>  
>>  
>>      private void doTestParser(String input, String expected) throws 
>> JasperException {
>> +        doTestParser(input, expected, input);
>> +    }
>> +
>> +    private void doTestParser(String input, String expectedResult, String 
>> expectedBuilderOutput) throws JasperException {
>> +
>>          ELException elException = null;
>>          String elResult = null;
>>  
>>          // Don't try and evaluate expressions that depend on variables or 
>> functions
>> -        if (expected != null) {
>> +        if (expectedResult != null) {
>>              try {
>>                  ELManager manager = new ELManager();
>>                  ELContext context = manager.getELContext();
>>                  ExpressionFactory factory = 
>> ELManager.getExpressionFactory();
>>                  ValueExpression ve = factory.createValueExpression(context, 
>> input, String.class);
>>                  elResult = ve.getValue(context).toString();
>> -                Assert.assertEquals(expected, elResult);
>> +                Assert.assertEquals(expectedResult, elResult);
>>              } catch (ELException ele) {
>>                  elException = ele;
>>              }
>> @@ -312,6 +319,6 @@ public class TestELParser {
>>  
>>          nodes.visit(textBuilder);
>>  
>> -        Assert.assertEquals(input, textBuilder.getText());
>> +        Assert.assertEquals(expectedBuilderOutput, textBuilder.getText());
>>      }
>>  }
>>
>> 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=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java (original)
>> +++ tomcat/trunk/test/org/apache/jasper/compiler/TestParser.java Thu Sep 10 
>> 13:18:02 2015
>> @@ -285,9 +285,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\"/>"));
>>
>> Modified: tomcat/trunk/test/webapp/bug45nnn/bug45427.jsp
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug45nnn/bug45427.jsp?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/webapp/bug45nnn/bug45427.jsp (original)
>> +++ tomcat/trunk/test/webapp/bug45nnn/bug45427.jsp Thu Sep 10 13:18:02 2015
>> @@ -21,21 +21,19 @@
>>      <p>00-${'hello world'}</p>
>>      <p>01-${'hello \'world'}</p>
>>      <p>02-${'hello "world'}</p>
>> -    <p>03-${"hello world"}</p>
>> -    <p>04-${"hello 'world"}</p>
>> -    <p>05-${"hello \"world"}</p>
>> +    <p>03-${'hello \"world'}</p>
>> +    <p>04-${"hello world"}</p>
>> +    <p>05-${"hello 'world"}</p>
>> +    <p>06-${"hello \'world"}</p>
>> +    <p>07-${"hello \"world"}</p>
>>  
>> -    <tags:echo echo="06-${'hello world'}" />
>> -    <tags:echo echo="07-${'hello \\\'world'}" />
>> -    <tags:echo echo="08-${'hello \"world'}" />
>> -    <tags:echo echo="09-${\"hello world\"}" />
>> -    <tags:echo echo="10-${\"hello 'world\"}" />
>> -    <tags:echo echo="11-${\"hello \\\"world\"}" />
>> -    <tags:echo echo='12-${\'hello world\'}' />
>> -    <tags:echo echo='13-${\'hello \\\'world\'}' />
>> -    <tags:echo echo='14-${\'hello "world\'}' />
>> -    <tags:echo echo='15-${"hello world"}' />
>> -    <tags:echo echo='16-${"hello \'world"}' />
>> -    <tags:echo echo='17-${"hello \\\"world"}' />
>> +    <tags:echo echo="08-${'hello world'}" />
>> +    <tags:echo echo="09-${'hello \'world'}" />
>> +    <tags:echo echo="10-${'hello "world'}" />
>> +    <tags:echo echo="11-${'hello \"world'}" />
>> +    <tags:echo echo='12-${"hello world"}' />
>> +    <tags:echo echo='13-${"hello 'world"}' />
>> +    <tags:echo echo='14-${"hello \'world"}' />
>> +    <tags:echo echo='15-${"hello \"world"}' />
>>    </body>
>>  </html>
>> \ No newline at end of file
>>
>> Modified: tomcat/trunk/test/webapp/bug45nnn/bug45451.jspf
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug45nnn/bug45451.jspf?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/webapp/bug45nnn/bug45451.jspf (original)
>> +++ tomcat/trunk/test/webapp/bug45nnn/bug45451.jspf Thu Sep 10 13:18:02 2015
>> @@ -19,14 +19,20 @@
>>  <p>02-\\${1+1}</p>
>>  <p>03-\\\${1+1}</p>
>>  <p>04-\$500</p>
>> +<p>05-${'\\$'}</p>
>> +<p>06-${'\\${'}</p>
>>  <tags:echo echo="10-${1+1}" />
>>  <tags:echo echo="11-\${1+1}" />
>>  <tags:echo echo="12-\\${1+1}" />
>>  <tags:echo echo="13-\\\${1+1}" />
>>  <tags:echo echo="14-\\\\${1+1}" />
>>  <tags:echo echo="15-\$500" />
>> +<tags:echo echo="16-${'\\$'}" />
>> +<tags:echo echo="17-${'\\${'}" />
>>  <tags:echo-deferred echo="20-#{1+1}" />
>>  <tags:echo-deferred echo="21-\#{1+1}" />
>>  <tags:echo-deferred echo="22-\\#{1+1}" />
>>  <tags:echo-deferred echo="23-\\\#{1+1}" />
>> -<tags:echo-deferred echo="24-\\\\#{1+1}" />
>> \ No newline at end of file
>> +<tags:echo-deferred echo="24-\\\\#{1+1}" />
>> +<tags:echo-deferred echo="25-#{'\\#'}" />
>> +<tags:echo-deferred echo="26-#{'\\#{'}" />
>> \ No newline at end of file
>>
>> Modified: tomcat/trunk/test/webapp/bug45nnn/bug45451a.jsp
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug45nnn/bug45451a.jsp?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/webapp/bug45nnn/bug45451a.jsp (original)
>> +++ tomcat/trunk/test/webapp/bug45nnn/bug45451a.jsp Thu Sep 10 13:18:02 2015
>> @@ -19,8 +19,6 @@
>>    <head><title>Bug 45451 test case</title></head>
>>    <body>
>>      <tags:echo echo="00-\\\'${'hello world'}\\\'" />
>> -    <tags:echo echo="01-\\\'${\"hello world\"}\\\'" />
>> -    <tags:echo echo='02-\\\'${\'hello world\'}\\\'' />
>> -    <tags:echo echo='03-\\\'${"hello world"}\\\'' />
>> +    <tags:echo echo='01-\\\'${"hello world"}\\\'' />
>>    </body>
>>  </html>
>> \ No newline at end of file
>>
>> Modified: tomcat/trunk/test/webapp/el-method.jsp
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/el-method.jsp?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/webapp/el-method.jsp (original)
>> +++ tomcat/trunk/test/webapp/el-method.jsp Thu Sep 10 13:18:02 2015
>> @@ -28,10 +28,10 @@
>>      pageContext.setAttribute("testBeanA", beanA, PageContext.REQUEST_SCOPE);
>>      pageContext.setAttribute("testBeanB", beanB, PageContext.REQUEST_SCOPE);
>>      %>
>> -    <tags:echo echo="00-${testBeanA[\"bean\"].sayHello('JUnit')}" />
>> +    <tags:echo echo="00-${testBeanA["bean"].sayHello('JUnit')}" />
>>      <tags:echo echo="01-${testBeanA.bean.sayHello('JUnit')}" />
>>      <tags:echo echo="02-${testBeanB.sayHello('JUnit')}" />
>> -    <tags:echo-deferred echo="03-#{testBeanA[\"bean\"].sayHello('JUnit')}" 
>> />
>> +    <tags:echo-deferred echo="03-#{testBeanA["bean"].sayHello('JUnit')}" />
>>      <tags:echo-deferred echo="04-#{testBeanA.bean.sayHello('JUnit')}" />
>>      <tags:echo-deferred echo="05-#{testBeanB.sayHello('JUnit')}" />
>>    </body>
>>
>> Modified: tomcat/trunk/test/webapp/el-misc.jsp
>> URL: 
>> http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/el-misc.jsp?rev=1702244&r1=1702243&r2=1702244&view=diff
>> ==============================================================================
>> --- tomcat/trunk/test/webapp/el-misc.jsp (original)
>> +++ tomcat/trunk/test/webapp/el-misc.jsp Thu Sep 10 13:18:02 2015
>> @@ -25,17 +25,17 @@
>>      <tags:echo echo="${'2'}az-04" />
>>      <tags:echo echo="05-a${'2'}z" />
>>      <tags:echo echo="06-az${'2'}" />
>> -    <tags:echo echo="${\"2\"}az-07" />
>> -    <tags:echo echo="08-a${\"2\"}z" />
>> -    <tags:echo echo="09-az${\"2\"}" />
>> +    <tags:echo echo="${"2"}az-07" />
>> +    <tags:echo echo="08-a${"2"}z" />
>> +    <tags:echo echo="09-az${"2"}" />
>>      <tags:echo echo="10-\${'foo'}${'bar'}" />
>> -    <tags:echo echo="11-${\"\\\"}\"}" />
>> +    <tags:echo echo="11-${"\\"}\"}" />
>>      <tags:echo echo="12-${'foo'}\\${'bar'}\\${'baz'}" />
>> -    <tags:echo echo="13-${'foo'}\\${\"bar\"}\\${'baz'}" />
>> -    <tags:echo echo="14-${\"foo\"}\\${'bar'}\\${\"baz\"}" />
>> -    <tags:echo echo='15-${\'foo\'}\\${"bar"}\\${\'baz\'}' />
>> -    <tags:echo echo='16-${"foo"}\\${\'bar\'}\\${"baz"}' />
>> -    <tags:echo echo='17-${"foo"}\\${&apos;bar&apos;}\\${&quot;baz&quot;}' />
>> +    <tags:echo echo="13-${'foo'}\\${"bar"}\\${'baz'}" />
>> +    <tags:echo echo="14-${"foo"}\\${'bar'}\\${"baz"}" />
>> +    <tags:echo echo='15-${'foo'}\\${"bar"}\\${'baz'}' />
>> +    <tags:echo echo='16-${"foo"}\\${'bar'}\\${"baz"}' />
>> +    <tags:echo 
>> echo='17-${"foo"}\\${"&apos;bar&apos;"}\\${"&quot;baz&quot;"}' />
>>      <tags:echo echo='18-${((x,y)->x+y)(1,2)}' />
>>      <tags:echo echo='19-${{1,2,3,4}.stream().max().orElse(-1)}' />
>>      <p>20-${{1,2,3,4}.stream().max().orElse(-1)}</p>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
>> For additional commands, e-mail: dev-h...@tomcat.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
> 


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

Reply via email to