You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/06/11 00:46:56 UTC

svn commit: r1601787 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/jasper/compiler/ java/org/apache/tomcat/util/net/ test/org/apache/el/ test/org/apache/jasper/compiler/ test/webapp-3.0/bug5nnnn/ webapps/docs/

Author: markt
Date: Tue Jun 10 22:46:55 2014
New Revision: 1601787

URL: http://svn.apache.org/r1601787
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56612
Correctly parse two consecutive escaped single quotes when used in UEL 
expression in a JSP.
Includes various unit tests that check the parsing of ${'\'\''}

Added:
    tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug56612.jsp
      - copied unchanged from r1601785, tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp
Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
    tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java
    tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java
    tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1601785

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1601787&r1=1601786&r2=1601787&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java Tue Jun 10 22:46:55 2014
@@ -745,7 +745,7 @@ class Parser implements TagConstants {
             // XXX could move this logic to JspReader
             last = reader.mark(); // XXX somewhat wasteful
             currentChar = reader.nextChar();
-            if (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
+            while (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
                 // skip character following '\' within quotes
                 reader.nextChar();
                 currentChar = reader.nextChar();

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java?rev=1601787&r1=1601786&r2=1601787&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java Tue Jun 10 22:46:55 2014
@@ -120,6 +120,7 @@ public class NioChannel implements ByteC
      */
     @Override
     public int write(ByteBuffer src) throws IOException {
+        System.out.println(Thread.currentThread().isInterrupted());
         return sc.write(src);
     }
 

Modified: tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java?rev=1601787&r1=1601786&r2=1601787&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java Tue Jun 10 22:46:55 2014
@@ -164,6 +164,11 @@ public class TestELEvaluation {
         assertEquals("\"\\", evaluateExpression("${\"\\\"\\\\\"}"));
     }
 
+    @Test
+    public void testMultipleEscaping() throws Exception {
+        assertEquals("''", evaluateExpression("${\"\'\'\"}"));
+    }
+
     private void compareBoth(String msg, int expected, Object o1, Object o2){
         int i1 = ELSupport.compare(o1, o2);
         int i2 = ELSupport.compare(o2, o1);

Modified: tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java?rev=1601787&r1=1601786&r2=1601787&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java Tue Jun 10 22:46:55 2014
@@ -488,6 +488,24 @@ public class TestELInJsp extends TomcatB
     }
 
 
+    @Test
+    public void testBug56612() throws Exception {
+        Tomcat tomcat = getTomcatInstance();
+
+        File appDir = new File("test/webapp-3.0");
+        // app dir is relative to server home
+        tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+        tomcat.start();
+
+        ByteChunk res = getUrl("http://localhost:" + getPort() +
+                "/test/bug5nnnn/bug56612.jsp");
+
+        String result = res.toString();
+        Assert.assertTrue(result.contains("00-''"));
+    }
+
+
     // Assertion for text contained with <p></p>, e.g. printed by tags:echo
     private static void assertEcho(String result, String expected) {
         assertTrue(result, result.indexOf("<p>" + expected + "</p>") > 0);

Modified: tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java?rev=1601787&r1=1601786&r2=1601787&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java Tue Jun 10 22:46:55 2014
@@ -266,6 +266,13 @@ public class TestELParser {
     }
 
 
+    @Test
+    public void testEscape11() throws JasperException {
+        // Bug 56612
+        doTestParser("${'\\'\\''}", "''");
+    }
+
+
     private void doTestParser(String input, String expected) throws JasperException {
         ELException elException = null;
         String elResult = null;

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1601787&r1=1601786&r2=1601787&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Jun 10 22:46:55 2014
@@ -112,6 +112,10 @@
         <bug>56561</bug>: Avoid <code>NoSuchElementException</code> while handling
         attributes with empty string value. (violetagg)
       </fix>
+      <fix>
+        <bug>56612</bug>: Correctly parse two consecutive escaped single quotes
+        when used in UEL expression in a JSP. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="WebSocket">



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


Re: svn commit: r1601787 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/jasper/compiler/ java/org/apache/tomcat/util/net/ test/org/apache/el/ test/org/apache/jasper/compiler/ test/webapp-3.0/bug5nnnn/ webapps/docs/

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-06-11 3:18 GMT+04:00 Mark Thomas <ma...@apache.org>:
> On 10/06/2014 23:55, Konstantin Kolinko wrote:
>> 2014-06-11 2:46 GMT+04:00  <ma...@apache.org>:
>>> Author: markt
>>> Date: Tue Jun 10 22:46:55 2014
>>> New Revision: 1601787
>>>
>>> URL: http://svn.apache.org/r1601787
>>> Log:
>>> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56612
>>> Correctly parse two consecutive escaped single quotes when used in UEL
>>> expression in a JSP.
>>> Includes various unit tests that check the parsing of ${'\'\''}
>>>
>>> Added:
>>>     tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug56612.jsp
>>>       - copied unchanged from r1601785, tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp
>>> Modified:
>>>     tomcat/tc7.0.x/trunk/   (props changed)
>>>     tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
>>>     tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
>>>     tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java
>>>     tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java
>>>     tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java
>>>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>>>
>>> Propchange: tomcat/tc7.0.x/trunk/
>>> ------------------------------------------------------------------------------
>>>   Merged /tomcat/trunk:r1601785
>>>
>>> Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
>>> URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1601787&r1=1601786&r2=1601787&view=diff
>>> ==============================================================================
>>> --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java (original)
>>> +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java Tue Jun 10 22:46:55 2014
>>> @@ -745,7 +745,7 @@ class Parser implements TagConstants {
>>>              // XXX could move this logic to JspReader
>>>              last = reader.mark(); // XXX somewhat wasteful
>>
>> 1. "last" is not advanced in this inner loop, nor it was inside the
>> old "if". It is likely a bug.
>
> I don't see how. It should be correct at the point it is used.
>

Ack. I see.
(For the record:
Those additional "reader.nextChar()" calls are performed only when
inside single or double quotes. To break the outer loop one has to
read a quote and to read a '}' character. The latter will update the
"last" pointer.
)

>> 2. If think the "if"s below were supposed to be a chain of "elseif"s.
>
> Looks like a clean-up that was never back-ported from 8 to 7. If you
> want to scratch that itch, go ahead.

Understood. I was looking at 6.0.x code at that moment.

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


Re: svn commit: r1601787 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/jasper/compiler/ java/org/apache/tomcat/util/net/ test/org/apache/el/ test/org/apache/jasper/compiler/ test/webapp-3.0/bug5nnnn/ webapps/docs/

Posted by Mark Thomas <ma...@apache.org>.
On 10/06/2014 23:55, Konstantin Kolinko wrote:
> 2014-06-11 2:46 GMT+04:00  <ma...@apache.org>:
>> Author: markt
>> Date: Tue Jun 10 22:46:55 2014
>> New Revision: 1601787
>>
>> URL: http://svn.apache.org/r1601787
>> Log:
>> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56612
>> Correctly parse two consecutive escaped single quotes when used in UEL
>> expression in a JSP.
>> Includes various unit tests that check the parsing of ${'\'\''}
>>
>> Added:
>>     tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug56612.jsp
>>       - copied unchanged from r1601785, tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp
>> Modified:
>>     tomcat/tc7.0.x/trunk/   (props changed)
>>     tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
>>     tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
>>     tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java
>>     tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java
>>     tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java
>>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>>
>> Propchange: tomcat/tc7.0.x/trunk/
>> ------------------------------------------------------------------------------
>>   Merged /tomcat/trunk:r1601785
>>
>> Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
>> URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1601787&r1=1601786&r2=1601787&view=diff
>> ==============================================================================
>> --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java (original)
>> +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java Tue Jun 10 22:46:55 2014
>> @@ -745,7 +745,7 @@ class Parser implements TagConstants {
>>              // XXX could move this logic to JspReader
>>              last = reader.mark(); // XXX somewhat wasteful
> 
> 1. "last" is not advanced in this inner loop, nor it was inside the
> old "if". It is likely a bug.

I don't see how. It should be correct at the point it is used.

> 2. If think the "if"s below were supposed to be a chain of "elseif"s.

Looks like a clean-up that was never back-ported from 8 to 7. If you
want to scratch that itch, go ahead.

> 3. It needs backport to Tomcat 6.

I'll propose the backport shortly.

> 4. A System.out.println has sneaked in below.

That was me debugging BZ 56518 - fixed.

> 
>>              currentChar = reader.nextChar();
>> -            if (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
>> +            while (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
>>                  // skip character following '\' within quotes
>>                  reader.nextChar();
>>                  currentChar = reader.nextChar();
>>
>> Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
>> URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java?rev=1601787&r1=1601786&r2=1601787&view=diff
>> ==============================================================================
>> --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java (original)
>> +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java Tue Jun 10 22:46:55 2014
>> @@ -120,6 +120,7 @@ public class NioChannel implements ByteC
>>       */
>>      @Override
>>      public int write(ByteBuffer src) throws IOException {
>> +        System.out.println(Thread.currentThread().isInterrupted());
>>          return sc.write(src);
>>      }
> 
> 
> (...)
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
> 


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


Re: svn commit: r1601787 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/jasper/compiler/ java/org/apache/tomcat/util/net/ test/org/apache/el/ test/org/apache/jasper/compiler/ test/webapp-3.0/bug5nnnn/ webapps/docs/

Posted by Konstantin Kolinko <kn...@gmail.com>.
2014-06-11 2:46 GMT+04:00  <ma...@apache.org>:
> Author: markt
> Date: Tue Jun 10 22:46:55 2014
> New Revision: 1601787
>
> URL: http://svn.apache.org/r1601787
> Log:
> Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56612
> Correctly parse two consecutive escaped single quotes when used in UEL
> expression in a JSP.
> Includes various unit tests that check the parsing of ${'\'\''}
>
> Added:
>     tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug56612.jsp
>       - copied unchanged from r1601785, tomcat/trunk/test/webapp/bug5nnnn/bug56612.jsp
> Modified:
>     tomcat/tc7.0.x/trunk/   (props changed)
>     tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
>     tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
>     tomcat/tc7.0.x/trunk/test/org/apache/el/TestELEvaluation.java
>     tomcat/tc7.0.x/trunk/test/org/apache/el/TestELInJsp.java
>     tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestELParser.java
>     tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
>
> Propchange: tomcat/tc7.0.x/trunk/
> ------------------------------------------------------------------------------
>   Merged /tomcat/trunk:r1601785
>
> Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java
> URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java?rev=1601787&r1=1601786&r2=1601787&view=diff
> ==============================================================================
> --- tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java (original)
> +++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/compiler/Parser.java Tue Jun 10 22:46:55 2014
> @@ -745,7 +745,7 @@ class Parser implements TagConstants {
>              // XXX could move this logic to JspReader
>              last = reader.mark(); // XXX somewhat wasteful

1. "last" is not advanced in this inner loop, nor it was inside the
old "if". It is likely a bug.
2. If think the "if"s below were supposed to be a chain of "elseif"s.
3. It needs backport to Tomcat 6.
4. A System.out.println has sneaked in below.

>              currentChar = reader.nextChar();
> -            if (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
> +            while (currentChar == '\\' && (singleQuoted || doubleQuoted)) {
>                  // skip character following '\' within quotes
>                  reader.nextChar();
>                  currentChar = reader.nextChar();
>
> Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java
> URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java?rev=1601787&r1=1601786&r2=1601787&view=diff
> ==============================================================================
> --- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java (original)
> +++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/net/NioChannel.java Tue Jun 10 22:46:55 2014
> @@ -120,6 +120,7 @@ public class NioChannel implements ByteC
>       */
>      @Override
>      public int write(ByteBuffer src) throws IOException {
> +        System.out.println(Thread.currentThread().isInterrupted());
>          return sc.write(src);
>      }


(...)

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