You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by lu...@apache.org on 2005/03/25 03:42:23 UTC
cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/xmlparser ParserUtils.java
luehe 2005/03/24 18:42:23
Modified: jasper2/src/share/org/apache/jasper/compiler Tag: TOMCAT_5_0
JspConfig.java
jasper2/src/share/org/apache/jasper/xmlparser Tag:
TOMCAT_5_0 ParserUtils.java
Log:
Fix for Bugzilla 34034 ("Jasper didn't respect external entities")
based on patch by <wi...@wilshire.com>
Revision Changes Path
No revision
No revision
1.16.2.1 +13 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspConfig.java
Index: JspConfig.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspConfig.java,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- JspConfig.java 17 Mar 2004 19:23:03 -0000 1.16
+++ JspConfig.java 25 Mar 2005 02:42:23 -0000 1.16.2.1
@@ -19,6 +19,7 @@
import java.io.InputStream;
import java.util.Iterator;
import java.util.Vector;
+import java.net.URL;
import javax.servlet.ServletContext;
@@ -27,6 +28,7 @@
import org.apache.jasper.JasperException;
import org.apache.jasper.xmlparser.ParserUtils;
import org.apache.jasper.xmlparser.TreeNode;
+import org.xml.sax.InputSource;
/**
* Handles the jsp-config element in WEB_INF/web.xml. This is used
@@ -60,14 +62,18 @@
InputStream is = null;
try {
- is = ctxt.getResourceAsStream(WEB_XML);
- if (is == null) {
+ URL uri = ctxt.getResource(WEB_XML);
+ if (uri == null) {
// no web.xml
- return;
+ return;
}
- ParserUtils pu = new ParserUtils();
- TreeNode webApp = pu.parseXMLDocument(WEB_XML, is);
+ is = uri.openStream();
+ InputSource ip = new InputSource(is);
+ ip.setSystemId(uri.toExternalForm());
+
+ ParserUtils pu = new ParserUtils();
+ TreeNode webApp = pu.parseXMLDocument(WEB_XML, ip);
if (webApp == null
|| !"2.4".equals(webApp.findAttribute("version"))) {
defaultIsELIgnored = "true";
@@ -173,6 +179,8 @@
jspProperties.addElement(propertyGroup);
}
}
+ } catch (Exception ex) {
+ throw new JasperException(ex);
} finally {
if (is != null) {
try {
No revision
No revision
1.10.2.1 +20 -3 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/xmlparser/ParserUtils.java
Index: ParserUtils.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/xmlparser/ParserUtils.java,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -r1.10 -r1.10.2.1
--- ParserUtils.java 17 Mar 2004 19:23:05 -0000 1.10
+++ ParserUtils.java 25 Mar 2005 02:42:23 -0000 1.10.2.1
@@ -76,12 +76,12 @@
* that corresponds to the root node of the document tree.
*
* @param uri URI of the XML document being parsed
- * @param is Input stream containing the deployment descriptor
+ * @param is Input source containing the deployment descriptor
*
* @exception JasperException if an input/output error occurs
* @exception JasperException if a parsing error occurs
*/
- public TreeNode parseXMLDocument(String uri, InputStream is)
+ public TreeNode parseXMLDocument(String uri, InputSource is)
throws JasperException {
Document document = null;
@@ -119,6 +119,23 @@
}
+ /**
+ * Parse the specified XML document, and return a <code>TreeNode</code>
+ * that corresponds to the root node of the document tree.
+ *
+ * @param uri URI of the XML document being parsed
+ * @param is Input stream containing the deployment descriptor
+ *
+ * @exception JasperException if an input/output error occurs
+ * @exception JasperException if a parsing error occurs
+ */
+ public TreeNode parseXMLDocument(String uri, InputStream is)
+ throws JasperException {
+
+ return (parseXMLDocument(uri, new InputSource(is)));
+ }
+
+
// ------------------------------------------------------ Protected Methods
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org