Author: markt Date: Thu Apr 10 23:25:06 2014 New Revision: 1586501 URL: http://svn.apache.org/r1586501 Log: Add a work around for validating XML documents (often TLDs) that use just the file name to refer to refer to the JavaEE schema on which they are based.
Modified: tomcat/tc6.0.x/trunk/STATUS.txt tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalResolver.java tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Modified: tomcat/tc6.0.x/trunk/STATUS.txt URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1586501&r1=1586500&r2=1586501&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/STATUS.txt (original) +++ tomcat/tc6.0.x/trunk/STATUS.txt Thu Apr 10 23:25:06 2014 @@ -28,14 +28,6 @@ None PATCHES PROPOSED TO BACKPORT: [ New proposals should be added at the end of the list ] -* Add a work around for validating XML documents (often TLDs) that use - just the file name to refer to refer to the JavaEE schema on which they - are based. - (Backport of r1579931) - https://people.apache.org/~kkolinko/patches/2014-04-05_tc6_LocalResolver_nameOnly.patch - +1: kkolinko, markt, schultz - -1: - PATCHES/ISSUES THAT ARE STALLED: Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalResolver.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalResolver.java?rev=1586501&r1=1586500&r2=1586501&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalResolver.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/LocalResolver.java Thu Apr 10 23:25:06 2014 @@ -37,6 +37,11 @@ public class LocalResolver implements En private static final StringManager sm = StringManager.getManager(Constants.PACKAGE_NAME); + private static final String[] JAVA_EE_NAMESPACES = { + XmlIdentifiers.JAVAEE_1_4_NS, + XmlIdentifiers.JAVAEE_5_NS }; + + private final Map<String,String> publicIds; private final Map<String,String> systemIds; private final boolean blockExternal; @@ -92,6 +97,18 @@ public class LocalResolver implements En return is; } + // Work-around for XML documents that use just the file name for the + // location to refer to a JavaEE schema + for (String javaEENamespace : JAVA_EE_NAMESPACES) { + String javaEESystemId = javaEENamespace + '/' + systemId; + resolved = systemIds.get(javaEESystemId); + if (resolved != null) { + InputSource is = new InputSource(resolved); + is.setPublicId(publicId); + return is; + } + } + // Resolve the supplied systemId against the base URI systemUri; try { Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java?rev=1586501&r1=1586500&r2=1586501&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/descriptor/XmlIdentifiers.java Thu Apr 10 23:25:06 2014 @@ -49,6 +49,8 @@ public final class XmlIdentifiers { "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"; // from J2EE 1.4 + public static final String JAVAEE_1_4_NS = + "http://java.sun.com/xml/ns/j2ee"; public static final String WEB_24_XSD = "http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"; public static final String TLD_20_XSD = @@ -57,6 +59,8 @@ public final class XmlIdentifiers { "http://www.ibm.com/webservices/xsd/j2ee_web_services_1_1.xsd"; // from JavaEE 5 + public static final String JAVAEE_5_NS = + "http://java.sun.com/xml/ns/javaee"; public static final String WEB_25_XSD = "http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; public static final String TLD_21_XSD = Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1586501&r1=1586500&r2=1586501&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original) +++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Thu Apr 10 23:25:06 2014 @@ -77,6 +77,11 @@ Prevent user supplied XSLTs used by the DefaultServlet from defining external entities. (markt) </fix> + <fix> + Add a work around for validating XML documents (often TLDs) that use + just the file name to refer to refer to the JavaEE schema on which they + are based. (kkolinko) + </fix> </changelog> </subsection> <subsection name="Coyote"> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org