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 2003/09/24 17:12:20 UTC
DO NOT REPLY [Bug 23388] New: -
Wrong assumtion on external XML-parser behavior
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23388>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23388
Wrong assumtion on external XML-parser behavior
Summary: Wrong assumtion on external XML-parser behavior
Product: Tomcat 4
Version: 4.1.27
Platform: All
OS/Version: All
Status: NEW
Severity: Major
Priority: Other
Component: Jasper 2
AssignedTo: tomcat-dev@jakarta.apache.org
ReportedBy: maverick_grey@mail.ru
It is well known fact that constructor InputSource(java.io.Reader reader) uses
encoding set in Reader and ignores actual encoding in xml declaration (for
example <?xml version="1.0" encoding="UTF-8"?>).
In the line 191 of org/apache/jasper/compiler/ParserController.java the reader
is opened with default encoding (see the line 168). After that it is passed as
an argument to JspDocumentParser.parse() in line 193. As a result, the code in
line 129 of org/apache/jasper/compiler/JspDocumentParser.java effectively
confuses an xml parser.
There are two small patches solving the problem
=== JspDocumentParser.diff ===
123c124
< InputStreamReader reader) {
---
> InputStream stream) {
129c130
< this.inputSource = new InputSource(reader);
---
> this.inputSource = new InputSource(stream);
139c140
< InputStreamReader reader,
---
> InputStream stream,
141c142
< JspDocumentParser handler = new JspDocumentParser(pc, path, reader);
---
> JspDocumentParser handler = new JspDocumentParser(pc, path, stream);
=== JspDocumentParser.diff ===
and
=== ParserController.diff ===
191d193
< reader = getReader(absFileName, encoding);
194,195c196,199
< reader, parent);
< } else {
---
> getInputStream(absFileName),
parent);
> }
> else {
> reader = getReader(absFileName, encoding);
220,221c226
< throws JasperException
< {
---
> throws JasperException {
297a306,314
> private InputStream getInputStream(String file)
> throws FileNotFoundException {
>
> InputStream in = ctxt.getResourceAsStream(file);
> if (in == null)
> throw new FileNotFoundException(file);
> return in;
> }
>
299,302c316
< throws FileNotFoundException, JasperException
< {
< InputStream in;
< InputStreamReader reader;
---
> throws FileNotFoundException, JasperException {
305,307c319
< in = ctxt.getResourceAsStream(file);
< if (in == null) {
< throw new FileNotFoundException(file);
---
> return new InputStreamReader(getInputStream(file), encoding);
309,310c321
< return new InputStreamReader(in, encoding);
< } catch (UnsupportedEncodingException ex) {
---
> catch (UnsupportedEncodingException ex) {
=== ParserController.diff ===
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org