Author: xavier Date: Fri Feb 29 04:03:19 2008 New Revision: 632301 URL: http://svn.apache.org/viewvc?rev=632301&view=rev Log: FIX: XML entity parsing does not work properly (IVY-737) (thanks to Patrick Woodworth)
Added: ant/ivy/core/trunk/test/repositories/xml-entities/ ant/ivy/core/trunk/test/repositories/xml-entities/bar.txt (with props) ant/ivy/core/trunk/test/repositories/xml-entities/foo.txt (with props) ant/ivy/core/trunk/test/repositories/xml-entities/ivy.xml (with props) ant/ivy/core/trunk/test/repositories/xml-entities/ivysettings.xml (with props) ant/ivy/core/trunk/test/repositories/xml-entities/module1/ ant/ivy/core/trunk/test/repositories/xml-entities/module1/ivy-1.0.xml (with props) ant/ivy/core/trunk/test/repositories/xml-entities/module2/ ant/ivy/core/trunk/test/repositories/xml-entities/module2/ivy-2.0.xml (with props) Modified: ant/ivy/core/trunk/CHANGES.txt ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Modified: ant/ivy/core/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=632301&r1=632300&r2=632301&view=diff ============================================================================== --- ant/ivy/core/trunk/CHANGES.txt (original) +++ ant/ivy/core/trunk/CHANGES.txt Fri Feb 29 04:03:19 2008 @@ -59,11 +59,13 @@ Jason Trump Tjeerd Verhagen John Williams + Patrick Woodworth Jaroslaw Wypychowski trunk version ===================================== - FIX: PublishEventsTest fails when Ivy sources are located in a directory with a + (IVY-755) +- FIX: XML entity parsing does not work properly (IVY-737) (thanks to Patrick Woodworth) 2.0.0-beta2 ===================================== Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java?rev=632301&r1=632300&r2=632301&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java Fri Feb 29 04:03:19 2008 @@ -43,6 +43,7 @@ import org.apache.ivy.util.url.URLHandlerRegistry; import org.xml.sax.Attributes; import org.xml.sax.SAXException; +import org.xml.sax.InputSource; import org.xml.sax.helpers.DefaultHandler; /** @@ -96,7 +97,9 @@ InputStream stream = null; try { stream = URLHandlerRegistry.getDefault().openStream(settingsUrl); - SAXParserFactory.newInstance().newSAXParser().parse(stream, this); + InputSource inSrc = new InputSource(stream); + inSrc.setSystemId(settingsUrl.toExternalForm()); + SAXParserFactory.newInstance().newSAXParser().parse(settingsUrl.toExternalForm(), this); } catch (IOException e) { throw e; } catch (Exception e) { Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java?rev=632301&r1=632300&r2=632301&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorUpdater.java Fri Feb 29 04:03:19 2008 @@ -57,6 +57,7 @@ import org.xml.sax.Attributes; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; +import org.xml.sax.InputSource; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.DefaultHandler; @@ -738,7 +739,10 @@ try { UpdaterHandler updaterHandler = new UpdaterHandler(settings, out, resolvedRevisions, status, revision, pubdate, ns, replaceInclude, confsToExclude, inStreamCtx); - XMLHelper.parse(in, null, updaterHandler, updaterHandler); + InputSource inSrc = new InputSource(in); + if (inStreamCtx != null) + inSrc.setSystemId(inStreamCtx.toExternalForm()); + XMLHelper.parse(inSrc, null, updaterHandler, updaterHandler); } catch (ParserConfigurationException e) { IllegalStateException ise = new IllegalStateException( "impossible to update Ivy files: parser problem"); Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java?rev=632301&r1=632300&r2=632301&view=diff ============================================================================== --- ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java (original) +++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/XMLHelper.java Fri Feb 29 04:03:19 2008 @@ -32,6 +32,7 @@ import org.w3c.dom.Document; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.InputSource; import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.DefaultHandler; @@ -94,7 +95,9 @@ throws SAXException, IOException, ParserConfigurationException { InputStream xmlStream = URLHandlerRegistry.getDefault().openStream(xmlURL); try { - parse(xmlStream, schema, handler, lHandler); + InputSource inSrc = new InputSource(xmlStream); + inSrc.setSystemId(xmlURL.toExternalForm()); + parse(inSrc, schema, handler, lHandler); } finally { try { xmlStream.close(); @@ -106,6 +109,12 @@ public static void parse( InputStream xmlStream, URL schema, DefaultHandler handler, LexicalHandler lHandler) + throws SAXException, IOException, ParserConfigurationException { + parse(new InputSource(xmlStream), schema, handler, lHandler ); + } + + public static void parse( + InputSource xmlStream, URL schema, DefaultHandler handler, LexicalHandler lHandler) throws SAXException, IOException, ParserConfigurationException { InputStream schemaStream = null; try { Modified: ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java?rev=632301&r1=632300&r2=632301&view=diff ============================================================================== --- ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java (original) +++ ant/ivy/core/trunk/test/java/org/apache/ivy/core/resolve/ResolveTest.java Fri Feb 29 04:03:19 2008 @@ -235,6 +235,21 @@ assertTrue(report.hasError()); } + public void testResolveWithXmlEntities() throws Exception { + Ivy ivy = new Ivy(); + Throwable th = null; + try { + ivy.configure(new File("test/repositories/xml-entities/ivysettings.xml").toURL()); + ResolveReport report = ivy.resolve(new File("test/repositories/xml-entities/ivy.xml").toURL(), + getResolveOptions(new String[] {"*"})); + assertNotNull(report); + assertFalse(report.hasError()); + } catch(Throwable e) { + th = e; + } + assertNull(th); + } + public void testResolveNoRevisionInPattern() throws Exception { // module1 depends on latest version of module2, for which there is no revision in the // pattern Added: ant/ivy/core/trunk/test/repositories/xml-entities/bar.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/xml-entities/bar.txt?rev=632301&view=auto ============================================================================== --- ant/ivy/core/trunk/test/repositories/xml-entities/bar.txt (added) +++ ant/ivy/core/trunk/test/repositories/xml-entities/bar.txt Fri Feb 29 04:03:19 2008 @@ -0,0 +1 @@ + <settings defaultResolver="myresolver"/> Propchange: ant/ivy/core/trunk/test/repositories/xml-entities/bar.txt ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ant/ivy/core/trunk/test/repositories/xml-entities/foo.txt URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/xml-entities/foo.txt?rev=632301&view=auto ============================================================================== --- ant/ivy/core/trunk/test/repositories/xml-entities/foo.txt (added) +++ ant/ivy/core/trunk/test/repositories/xml-entities/foo.txt Fri Feb 29 04:03:19 2008 @@ -0,0 +1,3 @@ + <dependencies> + <dependency conf="myconf->*" org="myorg" name="module2" rev="latest.integration" /> + </dependencies> Propchange: ant/ivy/core/trunk/test/repositories/xml-entities/foo.txt ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ant/ivy/core/trunk/test/repositories/xml-entities/ivy.xml URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/xml-entities/ivy.xml?rev=632301&view=auto ============================================================================== --- ant/ivy/core/trunk/test/repositories/xml-entities/ivy.xml (added) +++ ant/ivy/core/trunk/test/repositories/xml-entities/ivy.xml Fri Feb 29 04:03:19 2008 @@ -0,0 +1,29 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<!DOCTYPE ivy-module [ + <!ENTITY foo SYSTEM "foo.txt"> +]> +<ivy-module version="1.3"> + <info organisation="myorg" module="moduleB" revision="1.0"/> + <configurations> + <conf name="myconf"/> + </configurations> + <publications/> + &foo; +</ivy-module> Propchange: ant/ivy/core/trunk/test/repositories/xml-entities/ivy.xml ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ant/ivy/core/trunk/test/repositories/xml-entities/ivysettings.xml URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/xml-entities/ivysettings.xml?rev=632301&view=auto ============================================================================== --- ant/ivy/core/trunk/test/repositories/xml-entities/ivysettings.xml (added) +++ ant/ivy/core/trunk/test/repositories/xml-entities/ivysettings.xml Fri Feb 29 04:03:19 2008 @@ -0,0 +1,33 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<!DOCTYPE ivysettings [ + <!ENTITY bar SYSTEM "bar.txt"> +]> +<ivysettings> + &bar; + <resolvers> + <url name="myresolver"> + <ivy pattern="${ivy.settings.dir}/[module]/ivy-[revision].xml"/> + <artifact pattern="${ivy.settings.dir}/[module]/[artifact]-[revision].[ext]"/> + </url> + </resolvers> + <modules> + <module organisation="myorg" name=".*" resolver="myresolver"/> + </modules> +</ivysettings> Propchange: ant/ivy/core/trunk/test/repositories/xml-entities/ivysettings.xml ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ant/ivy/core/trunk/test/repositories/xml-entities/module1/ivy-1.0.xml URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/xml-entities/module1/ivy-1.0.xml?rev=632301&view=auto ============================================================================== --- ant/ivy/core/trunk/test/repositories/xml-entities/module1/ivy-1.0.xml (added) +++ ant/ivy/core/trunk/test/repositories/xml-entities/module1/ivy-1.0.xml Fri Feb 29 04:03:19 2008 @@ -0,0 +1,25 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<ivy-module version="1.3"> + <info organisation="myorg" module="module1" revision="1.0"/> + <configurations> + <conf name="myconf"/> + </configurations> + <publications/> +</ivy-module> Propchange: ant/ivy/core/trunk/test/repositories/xml-entities/module1/ivy-1.0.xml ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: ant/ivy/core/trunk/test/repositories/xml-entities/module2/ivy-2.0.xml URL: http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/repositories/xml-entities/module2/ivy-2.0.xml?rev=632301&view=auto ============================================================================== --- ant/ivy/core/trunk/test/repositories/xml-entities/module2/ivy-2.0.xml (added) +++ ant/ivy/core/trunk/test/repositories/xml-entities/module2/ivy-2.0.xml Fri Feb 29 04:03:19 2008 @@ -0,0 +1,28 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<ivy-module version="1.3"> + <info organisation="myorg" module="module2" revision="2.0"/> + <configurations> + <conf name="myconf"/> + </configurations> + <publications/> + <dependencies> + <dependency conf="myconf->*" org="myorg" name="module1" rev="1.0" /> + </dependencies> +</ivy-module> Propchange: ant/ivy/core/trunk/test/repositories/xml-entities/module2/ivy-2.0.xml ------------------------------------------------------------------------------ svn:mime-type = text/plain