Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E66F4DEEF for ; Thu, 25 Oct 2012 21:57:03 +0000 (UTC) Received: (qmail 75197 invoked by uid 500); 25 Oct 2012 21:57:03 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 75163 invoked by uid 500); 25 Oct 2012 21:57:03 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 75155 invoked by uid 99); 25 Oct 2012 21:57:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 21:57:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 21:57:02 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2893123888CD for ; Thu, 25 Oct 2012 21:56:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1402344 - in /ant/ivy/core/branches/2.3.x: ./ CHANGES.txt src/java/org/apache/ivy/plugins/parser/m2/PomReader.java src/java/org/apache/ivy/util/XMLHelper.java Date: Thu, 25 Oct 2012 21:56:18 -0000 To: notifications@ant.apache.org From: maartenc@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121025215619.2893123888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: maartenc Date: Thu Oct 25 21:56:17 2012 New Revision: 1402344 URL: http://svn.apache.org/viewvc?rev=1402344&view=rev Log: FIX: Ivy default cache path with non-ASCII character lets it crash (IVY-1378) (merged from trunk) Modified: ant/ivy/core/branches/2.3.x/ (props changed) ant/ivy/core/branches/2.3.x/CHANGES.txt ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/util/XMLHelper.java Propchange: ant/ivy/core/branches/2.3.x/ ------------------------------------------------------------------------------ Merged /ant/ivy/core/trunk:r1401854,1402340 Modified: ant/ivy/core/branches/2.3.x/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/CHANGES.txt?rev=1402344&r1=1402343&r2=1402344&view=diff ============================================================================== --- ant/ivy/core/branches/2.3.x/CHANGES.txt (original) +++ ant/ivy/core/branches/2.3.x/CHANGES.txt Thu Oct 25 21:56:17 2012 @@ -133,6 +133,7 @@ for detailed view of each issue, please - DOCUMENTATION: Documentation and Implementation mismatch of makepom (IVY-1383) (thanks to Thomas Kurpick) - DOCUMENTATION: added link to extra beginners guide (IVY-1381) +- FIX: Ivy default cache path with non-ASCII character lets it crash (IVY-1378) - FIX: latest.integration isn't resolved against a Maven snapshot repository (when uniqueVersion = true) (IVY-1036) - FIX: Resolve does not deliver all dependent artifacts (IVY-1366) (thanks to Wolfgang Frank) - FIX: Ivy descriptors are merged incorrectly when there is an element (IVY-1356) Modified: ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java?rev=1402344&r1=1402343&r2=1402344&view=diff ============================================================================== --- ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java (original) +++ ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/plugins/parser/m2/PomReader.java Thu Oct 25 21:56:17 2012 @@ -48,8 +48,6 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; - - /** * Provides the method to read some data out of the DOM tree of a pom * file. @@ -91,8 +89,10 @@ public class PomReader { public PomReader(URL descriptorURL, Resource res) throws IOException, SAXException { InputStream stream = new AddDTDFilterInputStream(URLHandlerRegistry.getDefault().openStream(descriptorURL)); + InputSource source = new InputSource(stream); + source.setSystemId(XMLHelper.toSystemId(descriptorURL)); try { - Document pomDomDoc = XMLHelper.parseToDom(stream, res, new EntityResolver() { + Document pomDomDoc = XMLHelper.parseToDom(source, new EntityResolver() { public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { if ((systemId != null) && systemId.endsWith("m2-entities.ent")) { @@ -109,12 +109,10 @@ public class PomReader { } parentElement = getFirstChildElement(projectElement , PARENT); } finally { - if (stream != null) { - try { - stream.close(); - } catch (IOException e) { - // ignore - } + try { + stream.close(); + } catch (IOException e) { + // ignore } } } Modified: ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/util/XMLHelper.java URL: http://svn.apache.org/viewvc/ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/util/XMLHelper.java?rev=1402344&r1=1402343&r2=1402344&view=diff ============================================================================== --- ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/util/XMLHelper.java (original) +++ ant/ivy/core/branches/2.3.x/src/java/org/apache/ivy/util/XMLHelper.java Thu Oct 25 21:56:17 2012 @@ -19,6 +19,8 @@ package org.apache.ivy.util; import java.io.IOException; import java.io.InputStream; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import javax.xml.parsers.DocumentBuilder; @@ -77,6 +79,17 @@ public abstract class XMLHelper { return parser; } + /** + * Convert an URL to a valid systemId according to RFC 2396. + */ + public static String toSystemId(URL url) { + try { + return new URI(url.toExternalForm()).toASCIIString(); + } catch (URISyntaxException e) { + return url.toExternalForm(); + } + } + // IMPORTANT: validation errors are only notified to the given handler, and // do not cause exception // implement warning error and fatalError methods in handler to be informed @@ -92,7 +105,7 @@ public abstract class XMLHelper { InputStream xmlStream = URLHandlerRegistry.getDefault().openStream(xmlURL); try { InputSource inSrc = new InputSource(xmlStream); - inSrc.setSystemId(xmlURL.toExternalForm()); + inSrc.setSystemId(toSystemId(xmlURL)); parse(inSrc, schema, handler, lHandler); } finally { try { @@ -189,20 +202,10 @@ public abstract class XMLHelper { } - public static Document parseToDom( - InputStream stream, Resource res, EntityResolver entityResolver) - throws IOException, SAXException { + public static Document parseToDom(InputSource source, EntityResolver entityResolver) + throws IOException, SAXException { DocumentBuilder docBuilder = getDocBuilder(entityResolver); - Document pomDomDoc; - try { - pomDomDoc = docBuilder.parse(stream, res.getName()); - } catch (SAXException e) { - e.printStackTrace(); - throw e; - } finally { - stream.close(); - } - return pomDomDoc; + return docBuilder.parse(source); } public static DocumentBuilder getDocBuilder(EntityResolver entityResolver) {