Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4DF39200B99 for ; Wed, 5 Oct 2016 11:41:02 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 4C828160ADE; Wed, 5 Oct 2016 09:41:02 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 62F09160ADB for ; Wed, 5 Oct 2016 11:41:01 +0200 (CEST) Received: (qmail 93235 invoked by uid 500); 5 Oct 2016 09:41:00 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 93225 invoked by uid 99); 5 Oct 2016 09:41:00 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Oct 2016 09:41:00 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id EC125C0D64 for ; Wed, 5 Oct 2016 09:40:59 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 3sUxNEi1Ji1T for ; Wed, 5 Oct 2016 09:40:58 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 075735FAD5 for ; Wed, 5 Oct 2016 09:40:58 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C0D21E0425 for ; Wed, 5 Oct 2016 09:40:56 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id F0A883A00EC for ; Wed, 5 Oct 2016 09:40:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1763375 - in /tomcat/trunk: build.xml java/org/apache/catalina/webresources/war/WarURLConnection.java java/org/apache/tomcat/util/buf/UriUtil.java java/org/apache/tomcat/util/scan/JarFactory.java Date: Wed, 05 Oct 2016 09:40:55 -0000 To: dev@tomcat.apache.org From: markt@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20161005094055.F0A883A00EC@svn01-us-west.apache.org> archived-at: Wed, 05 Oct 2016 09:41:02 -0000 Author: markt Date: Wed Oct 5 09:40:54 2016 New Revision: 1763375 URL: http://svn.apache.org/viewvc?rev=1763375&view=rev Log: Add support for using 'war:file:...' URLs to refer to WAR files rather than 'jar:file:...' Modified: tomcat/trunk/build.xml tomcat/trunk/java/org/apache/catalina/webresources/war/WarURLConnection.java tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java tomcat/trunk/java/org/apache/tomcat/util/scan/JarFactory.java Modified: tomcat/trunk/build.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/build.xml?rev=1763375&r1=1763374&r2=1763375&view=diff ============================================================================== --- tomcat/trunk/build.xml (original) +++ tomcat/trunk/build.xml Wed Oct 5 09:40:54 2016 @@ -339,6 +339,7 @@ + Modified: tomcat/trunk/java/org/apache/catalina/webresources/war/WarURLConnection.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/webresources/war/WarURLConnection.java?rev=1763375&r1=1763374&r2=1763375&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/webresources/war/WarURLConnection.java (original) +++ tomcat/trunk/java/org/apache/catalina/webresources/war/WarURLConnection.java Wed Oct 5 09:40:54 2016 @@ -22,6 +22,8 @@ import java.net.URL; import java.net.URLConnection; import java.security.Permission; +import org.apache.tomcat.util.buf.UriUtil; + public class WarURLConnection extends URLConnection { @@ -30,18 +32,7 @@ public class WarURLConnection extends UR protected WarURLConnection(URL url) throws IOException { super(url); - - // Need to make this look like a JAR URL for the WAR file - // Assumes that the spec is absolute and starts war:file:/... - String file = url.getFile(); - if (file.contains("*/")) { - file = file.replaceFirst("\\*/", "!/"); - } else { - file = file.replaceFirst("\\^/", "!/"); - } - - URL innerJarUrl = new URL("jar", url.getHost(), url.getPort(), file); - + URL innerJarUrl = UriUtil.warToJar(url); wrappedJarUrlConnection = innerJarUrl.openConnection(); } Modified: tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java?rev=1763375&r1=1763374&r2=1763375&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/buf/UriUtil.java Wed Oct 5 09:40:54 2016 @@ -128,4 +128,27 @@ public final class UriUtil { tmp = PATTERN_CARET.matcher(tmp).replaceAll("%5e/"); return PATTERN_ASTERISK.matcher(tmp).replaceAll("%2a/"); } + + + /** + * Convert a URL of the form war:file:... to + * war:file:.... + * + * @param warUrl The WAR URL to convert + * + * @return The equivalent JAR URL + * + * @throws MalformedURLException If the conversion fails + */ + public static URL warToJar(URL warUrl) throws MalformedURLException { + // Assumes that the spec is absolute and starts war:file:/... + String file = warUrl.getFile(); + if (file.contains("*/")) { + file = file.replaceFirst("\\*/", "!/"); + } else { + file = file.replaceFirst("\\^/", "!/"); + } + + return new URL("jar", warUrl.getHost(), warUrl.getPort(), file); + } } Modified: tomcat/trunk/java/org/apache/tomcat/util/scan/JarFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/scan/JarFactory.java?rev=1763375&r1=1763374&r2=1763375&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/scan/JarFactory.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/scan/JarFactory.java Wed Oct 5 09:40:54 2016 @@ -21,6 +21,7 @@ import java.net.MalformedURLException; import java.net.URL; import org.apache.tomcat.Jar; +import org.apache.tomcat.util.buf.UriUtil; /** * Provide a mechanism to obtain objects that implement {@link Jar}. @@ -31,21 +32,26 @@ public class JarFactory { // Factory class. Hide public constructor. } + public static Jar newInstance(URL url) throws IOException { - String jarUrl = url.toString(); - if (jarUrl.startsWith("jar:file:")) { - if (jarUrl.endsWith("!/")) { + String urlString = url.toString(); + if (urlString.startsWith("jar:file:")) { + if (urlString.endsWith("!/")) { return new JarFileUrlJar(url, true); } else { return new JarFileUrlNestedJar(url); } - } else if (jarUrl.startsWith("file:")) { + } else if (urlString.startsWith("war:file:")) { + URL jarUrl = UriUtil.warToJar(url); + return new JarFileUrlNestedJar(jarUrl); + } else if (urlString.startsWith("file:")) { return new JarFileUrlJar(url, false); } else { return new UrlJar(url); } } + public static URL getJarEntryURL(URL baseUrl, String entryName) throws MalformedURLException { --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org