tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1574657 - in /tomcat/trunk: java/org/apache/jasper/Constants.java java/org/apache/jasper/JspC.java java/org/apache/jasper/servlet/JspCServletContext.java webapps/docs/changelog.xml
Date Wed, 05 Mar 2014 21:01:51 GMT
Author: markt
Date: Wed Mar  5 21:01:50 2014
New Revision: 1574657

URL: http://svn.apache.org/r1574657
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56199
Restore validateXml option to JspC

Modified:
    tomcat/trunk/java/org/apache/jasper/Constants.java
    tomcat/trunk/java/org/apache/jasper/JspC.java
    tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/jasper/Constants.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/Constants.java?rev=1574657&r1=1574656&r2=1574657&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/Constants.java (original)
+++ tomcat/trunk/java/org/apache/jasper/Constants.java Wed Mar  5 21:01:50 2014
@@ -162,6 +162,16 @@ public class Constants {
             "org.apache.jasper.XML_VALIDATE_TLD";
 
     /**
+     * Name of the ServletContext init-param that determines if the XML parser
+     * used for web.xml files will be validating or not. Note that this is only
+     * used when using JspC. In normal operation, Jasper obtains the JspConfig
+     * information directly from the ServletContext and therefore does not need
+     * to parse web.xml.
+     */
+    public static final String XML_VALIDATION_INIT_PARAM =
+            "org.apache.jasper.XML_VALIDATE";
+
+    /**
      * Name of the ServletContext init-param that determines if the XML parsers
      * will block the resolution of external entities.
      * <p>

Modified: tomcat/trunk/java/org/apache/jasper/JspC.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspC.java?rev=1574657&r1=1574656&r2=1574657&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspC.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspC.java Wed Mar  5 21:01:50 2014
@@ -134,6 +134,7 @@ public class JspC extends Task implement
     protected static final String SWITCH_SMAP = "-smap";
     protected static final String SWITCH_DUMP_SMAP = "-dumpsmap";
     protected static final String SWITCH_VALIDATE_TLD = "-validateTld";
+    protected static final String SWITCH_VALIDATE_XML = "-validateXml";
     protected static final String SWITCH_BLOCK_EXTERNAL = "-blockExternal";
     protected static final String SWITCH_NO_BLOCK_EXTERNAL = "-no-blockExternal";
     protected static final String SHOW_SUCCESS ="-s";
@@ -167,6 +168,7 @@ public class JspC extends Task implement
     protected boolean trimSpaces = false;
     protected boolean genStringAsCharArray = false;
     protected boolean validateTld;
+    protected boolean validateXml;
     protected boolean blockExternal = true;
     protected boolean xpoweredBy;
     protected boolean mappedFile = false;
@@ -376,6 +378,8 @@ public class JspC extends Task implement
                 smapDumped = true;
             } else if (tok.equals(SWITCH_VALIDATE_TLD)) {
                 setValidateTld(true);
+            } else if (tok.equals(SWITCH_VALIDATE_XML)) {
+                setValidateXml(true);
             } else if (tok.equals(SWITCH_BLOCK_EXTERNAL)) {
                 setBlockExternal(true);
             } else if (tok.equals(SWITCH_NO_BLOCK_EXTERNAL)) {
@@ -867,6 +871,14 @@ public class JspC extends Task implement
         return validateTld;
     }
 
+    public void setValidateXml( boolean b ) {
+        this.validateXml = b;
+    }
+
+    public boolean isValidateXml() {
+        return validateXml;
+    }
+
     public void setBlockExternal( boolean b ) {
         this.blockExternal = b;
     }
@@ -1455,9 +1467,14 @@ public class JspC extends Task implement
         if (isValidateTld()) {
             context.setInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM, "true");
         }
+        if (isValidateXml()) {
+            context.setInitParameter(Constants.XML_VALIDATION_INIT_PARAM, "true");
+        }
         context.setInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM,
                 String.valueOf(isBlockExternal()));
 
+        context.processWebXml();
+
         TldScanner scanner = new TldScanner(
                 context, true, isValidateTld(), isBlockExternal());
         scanner.setClassLoader(classLoader);

Modified: tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java?rev=1574657&r1=1574656&r2=1574657&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java (original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java Wed Mar  5 21:01:50
2014
@@ -97,10 +97,10 @@ public class JspCServletContext implemen
     /**
      * Merged web.xml for the application.
      */
-    private final WebXml webXml;
+    private WebXml webXml;
 
 
-    private final JspConfigDescriptor jspConfigDescriptor;
+    private JspConfigDescriptor jspConfigDescriptor;
 
     /**
      * Web application class loader.
@@ -125,7 +125,9 @@ public class JspCServletContext implemen
         myLogWriter = aLogWriter;
         myResourceBaseURL = aResourceBaseURL;
         this.loader = classLoader;
+    }
 
+    public void processWebXml() throws JasperException {
         this.webXml = buildMergedWebXml();
         jspConfigDescriptor = webXml.getJspConfigDescriptor();
     }
@@ -140,7 +142,9 @@ public class JspCServletContext implemen
         } else {
             blockExternal = Boolean.parseBoolean(blockExternalString);
         }
-        WebXmlParser webXmlParser = new WebXmlParser(false, false, blockExternal);
+        boolean validate = Boolean.parseBoolean(
+                getInitParameter(Constants.XML_VALIDATION_INIT_PARAM));
+        WebXmlParser webXmlParser = new WebXmlParser(validate, validate, blockExternal);
         // Use this class's classloader as Ant will have set the TCCL to its own
         webXmlParser.setClassLoader(getClass().getClassLoader());
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1574657&r1=1574656&r2=1574657&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Mar  5 21:01:50 2014
@@ -119,6 +119,10 @@
       <fix>
         Remove an unnecessary null check identified by FindBugs. (markt)
       </fix>
+      <fix>
+        <bug>56199</bug>: Restore validateXml option for JspC which determines
+        if web.xml will be parsed with a validating parser. (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


Mime
View raw message