Author: markt
Date: Thu Mar 6 07:40:12 2014
New Revision: 1574785
URL: http://svn.apache.org/r1574785
Log:
Better fix for BZ56199
Fix failing unit tests caused by original fix.
Modified:
tomcat/trunk/java/org/apache/jasper/JspC.java
tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java
Modified: tomcat/trunk/java/org/apache/jasper/JspC.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/JspC.java?rev=1574785&r1=1574784&r2=1574785&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/JspC.java (original)
+++ tomcat/trunk/java/org/apache/jasper/JspC.java Thu Mar 6 07:40:12 2014
@@ -1463,17 +1463,11 @@ public class JspC extends Task implement
PrintWriter log = new PrintWriter(System.out);
URL resourceBase = new
File(uriRoot).getCanonicalFile().toURI().toURL();
- context = new JspCServletContext(log, resourceBase, classLoader);
+ context = new JspCServletContext(log, resourceBase, classLoader,
+ isValidateXml(), isBlockExternal());
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());
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=1574785&r1=1574784&r2=1574785&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java
(original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/JspCServletContext.java Thu Mar
6 07:40:12 2014
@@ -45,7 +45,6 @@ import javax.servlet.SessionCookieConfig
import javax.servlet.SessionTrackingMode;
import javax.servlet.descriptor.JspConfigDescriptor;
-import org.apache.jasper.Constants;
import org.apache.jasper.JasperException;
import org.apache.jasper.compiler.Localizer;
import org.apache.jasper.util.ExceptionUtils;
@@ -115,35 +114,28 @@ public class JspCServletContext implemen
*
* @param aLogWriter PrintWriter which is used for <code>log()</code> calls
* @param aResourceBaseURL Resource base URL
+ * @param classLoader Class loader for this {@link ServletContext}
+ * @param validate Should a validating parser be used to parse
web.xml?
+ * @param blockExternal Should external entities be blocked when parsing
+ * web.xml?
* @throws JasperException
*/
- public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL,
ClassLoader classLoader)
- throws JasperException {
+ public JspCServletContext(PrintWriter aLogWriter, URL aResourceBaseURL,
+ ClassLoader classLoader, boolean validate, boolean blockExternal)
+ throws JasperException {
myAttributes = new HashMap<>();
myParameters = new ConcurrentHashMap<>();
myLogWriter = aLogWriter;
myResourceBaseURL = aResourceBaseURL;
this.loader = classLoader;
- }
-
- public void processWebXml() throws JasperException {
- this.webXml = buildMergedWebXml();
+ this.webXml = buildMergedWebXml(validate, blockExternal);
jspConfigDescriptor = webXml.getJspConfigDescriptor();
}
- private WebXml buildMergedWebXml() throws JasperException {
+ private WebXml buildMergedWebXml(boolean validate, boolean blockExternal)
+ throws JasperException {
WebXml webXml = new WebXml();
- String blockExternalString = getInitParameter(
- Constants.XML_BLOCK_EXTERNAL_INIT_PARAM);
- boolean blockExternal;
- if (blockExternalString == null) {
- blockExternal = true;
- } else {
- blockExternal = Boolean.parseBoolean(blockExternalString);
- }
- 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/test/org/apache/jasper/servlet/TestJspCServletContext.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java?rev=1574785&r1=1574784&r2=1574785&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java
(original)
+++ tomcat/trunk/test/org/apache/jasper/servlet/TestJspCServletContext.java Thu
Mar 6 07:40:12 2014
@@ -31,8 +31,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp() throws Exception {
File appDir = new File("test/webapp");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(3, context.getEffectiveMajorVersion());
Assert.assertEquals(1, context.getEffectiveMinorVersion());
JspConfigDescriptor jspConfigDescriptor =
@@ -62,8 +62,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp_2_2() throws Exception {
File appDir = new File("test/webapp-2.2");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(2, context.getEffectiveMajorVersion());
Assert.assertEquals(2, context.getEffectiveMinorVersion());
}
@@ -71,8 +71,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp_2_3() throws Exception {
File appDir = new File("test/webapp-2.3");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(2, context.getEffectiveMajorVersion());
Assert.assertEquals(3, context.getEffectiveMinorVersion());
}
@@ -80,8 +80,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp_2_4() throws Exception {
File appDir = new File("test/webapp-2.4");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(2, context.getEffectiveMajorVersion());
Assert.assertEquals(4, context.getEffectiveMinorVersion());
}
@@ -89,8 +89,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp_2_5() throws Exception {
File appDir = new File("test/webapp-2.5");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(2, context.getEffectiveMajorVersion());
Assert.assertEquals(5, context.getEffectiveMinorVersion());
}
@@ -98,8 +98,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp_3_0() throws Exception {
File appDir = new File("test/webapp-3.0");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(3, context.getEffectiveMajorVersion());
Assert.assertEquals(0, context.getEffectiveMinorVersion());
}
@@ -107,8 +107,8 @@ public class TestJspCServletContext {
@Test
public void testWebapp_3_1() throws Exception {
File appDir = new File("test/webapp-3.1");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(3, context.getEffectiveMajorVersion());
Assert.assertEquals(1, context.getEffectiveMinorVersion());
}
@@ -116,8 +116,8 @@ public class TestJspCServletContext {
@Test
public void testWebresources() throws Exception {
File appDir = new File("test/webresources/dir1");
- JspCServletContext context =
- new JspCServletContext(null, appDir.toURI().toURL(), null);
+ JspCServletContext context = new JspCServletContext(
+ null, appDir.toURI().toURL(), null, false, false);
Assert.assertEquals(3, context.getEffectiveMajorVersion());
Assert.assertEquals(1, context.getEffectiveMinorVersion());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]