Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 52648 invoked from network); 5 Apr 2004 21:26:48 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 5 Apr 2004 21:26:48 -0000 Received: (qmail 93367 invoked by uid 500); 5 Apr 2004 21:26:35 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 93016 invoked by uid 500); 5 Apr 2004 21:26:33 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 92994 invoked by uid 500); 5 Apr 2004 21:26:33 -0000 Received: (qmail 92991 invoked from network); 5 Apr 2004 21:26:33 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 5 Apr 2004 21:26:33 -0000 Received: (qmail 52618 invoked by uid 1818); 5 Apr 2004 21:26:45 -0000 Date: 5 Apr 2004 21:26:45 -0000 Message-ID: <20040405212645.52617.qmail@minotaur.apache.org> From: mbenson@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/main/org/apache/tools/ant/launch Locator.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N mbenson 2004/04/05 14:26:45 Modified: src/main/org/apache/tools/ant/launch Locator.java Log: Fix the previous change; handle invalid URLs and 1.2 compatibility. Submitted by: Martijn Kruithof, Rainer Noack Revision Changes Path 1.13 +15 -11 ant/src/main/org/apache/tools/ant/launch/Locator.java Index: Locator.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/launch/Locator.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Locator.java 2 Apr 2004 20:20:43 -0000 1.12 +++ Locator.java 5 Apr 2004 21:26:45 -0000 1.13 @@ -101,21 +101,25 @@ * @since Ant 1.6 */ public static String fromURI(String uri) { + URL url = null; try { - URL url = new URL(uri); - if (!("file".equals(url.getProtocol()))) { - throw new IllegalArgumentException("Can only handle file: URIs"); - } - StringBuffer buf = new StringBuffer(url.getHost()); - if (buf.length() > 0) { - buf.insert(0, "//"); - } - buf.append(url.getPath()); - uri = buf.toString(); + url = new URL(uri); } catch (MalformedURLException emYouEarlEx) { } + if (url == null || !("file".equals(url.getProtocol()))) { + throw new IllegalArgumentException("Can only handle valid file: URIs"); + } + StringBuffer buf = new StringBuffer(url.getHost()); + if (buf.length() > 0) { + buf.insert(0, File.separatorChar).insert(0, File.separatorChar); + } + + String file = url.getFile(); + int queryPos = file.indexOf('?'); + buf.append((queryPos < 0) ? file : file.substring(0, queryPos)); + + uri = buf.toString().replace('/', File.separatorChar); - uri = uri.replace('/', File.separatorChar); if (File.pathSeparatorChar == ';' && uri.startsWith("\\") && uri.length() > 2 && Character.isLetter(uri.charAt(1)) && uri.lastIndexOf(':') > -1) { uri = uri.substring(1); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org