You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2020/01/16 18:14:44 UTC

[Bug 64081] New: Fix for 49464 looks to introduced a regression on jstl's import tag support under certain condition

https://bz.apache.org/bugzilla/show_bug.cgi?id=64081

            Bug ID: 64081
           Summary: Fix for 49464 looks to introduced a regression on
                    jstl's import tag support under certain condition
           Product: Tomcat 9
           Version: 9.0.26
          Hardware: PC
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: fuminzhou@crd.com
  Target Milestone: -----

Created attachment 36968
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36968&action=edit
A demonstration webapp zip of the issue behavior.

A simple jsp below could demonstrate the issue behavior - when it is used with
javax.servlet.jsp.jstl-1.2.3.jar and javax.servlet.jsp.jstl-api-1.2.1.jar
instead of taglibs-standard-impl-1.2.5.jar and taglibs-standard-spec-1.2.5.jar.
 I have also created a simple webapp with such. Some environment factors might
play - Windows 10 pro with en-US/Eastern Time zone was used when the issue was
encountered. java version is 11.0.5 was used but looks not relavent.

<!--begin of jsp>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<fmt:setLocale value='' scope="session"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ShowBug</title>
</head>
<body>
    <div id="xsltnot"> c:import is not expected to get the contents in between
-<br>
        ---------------------------------------------<br>
        <c:import var="xslt" url="/sample.txt"/><br>
        ---------------------------------------------<br>
    </div>
    <br>
    <br>
    <div id="xslt"> Instead, we expect the c:import to get the contents into
the variable, which should be displayed in between *<br>
    ********************************************<br>
        <c:out value="${xslt}" escapeXml="true"/><br>
    ********************************************<br>
    </div>
</body>
</html>
<!-- end of jsp>

Attached is also webapp bug.zip.  Deployed it to a Tomcat 9.0.26 clean web
server, accessing the <http://localhost:8080>/bug/ShowBug.jsp, would get the
contents from import tag to show up in the result html, while the variable left
empty - which is not expected, while /bug/ShowNoBug.jsp would show the expected
behavior, with the result html not receiving the content from the import
target, but the variable gets populated.

The behavior is also observed with Tomcat 8.5.45, where the fix for 49464 had
been back patched. Tomcat 8.5.32 that does not contain the fix, does not show
to have the issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 64081] Fix for 49464 looks to introduced a regression on jstl's import tag support under certain condition

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64081

--- Comment #3 from fuminzhou@crd.com ---
Thought this might be one possibility of the verdict. :)
Still, thanks.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 64081] Fix for 49464 looks to introduced a regression on jstl's import tag support under certain condition

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64081

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Mark Thomas <ma...@apache.org> ---
This is a bug in the JSTL implementation you are using.

It is triggered because:
- a Locale is set so an explicit encoding is defined
- the explicit encoding is different from the encoding the DefaultServlet is
  configured with for text files
- so a conversion is required
- so the DefaultServlet performs the conversion via a Writer
- the Writer is flushed at the end of the content

The JSTL implementation incorrectly writes the flushed bytes directly to the
output.

You will see this bug anytime you include a resource that outputs via a Writer.

This appears to be the commit where the bug is introduced:
https://github.com/javaee/jstl-api/commit/e41c5e89191ceafbeb67bdd912d227c5e848086a#diff-67ef836e5934df8c921cd2fbdf29518c

I recommend you use the JSTL implementation from the ASF that does not have
this bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 64081] Fix for 49464 looks to introduced a regression on jstl's import tag support under certain condition

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64081

fuminzhou@crd.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from fuminzhou@crd.com ---
A description of the issue:
Fix to bug 49464 looks to introduced a new bug/regression for jstl import tag
under certain conditions:
1. When jstl's fmt:setLocale is also used.
2. javax.servlet.jsp.jstl-1.2.3.jar is used. (later test indicates the issue
happens with javax.servlet.jsp.jstl-1.2.5.jar as well).

The issue behavior:
For the import tag such as
<c:import var="var1" url="/sample.txt"/>
the expectation is var1 would be populated with the contents of sample.txt -
and the page itself not getting the file contents.

However, with tomcat 9.0.26 (with the bug 49464 fix), it is observed that the
var1 is left empty, while the containing jsp's generated result html would
contain the contents of the sample.txt.

Investigation:
under the above mentioned conditions, 
1. Tomcat's org.apache.catalina.servlets.DefaultServlet at about line 1025
(9.0.26), 
"outputEncoding != org.apache.coyote.Constants.DEFAULT_BODY_CHARSET.name()"
would yield a true even when the contents of both left and right sides are the
same.
2. The boolean outputEncodingSpecified being true would further branch the code
flow in about line 1108-1112 to pw.flush.
3. these looks to flush the contents into the response, and voided the internal
buffer which is used to populate the variable.
And the result is the result html contents get the import contents, while the
variable does not.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org