classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] [RFC] XML - fix for XMLParser's URL problem


From: Robert Schuster
Subject: [cp-patches] [RFC] XML - fix for XMLParser's URL problem
Date: Fri, 07 Oct 2005 04:54:35 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.12) Gecko/20051005

Hi,
here is probably a fix for PR classpath/24249 [0].

2005-10-07  Robert Schuster  <address@hidden>

    * gnu/xml/aelfred2/SAXDriver.java:
    (absolutize): Replaced URL.toString() with explicit
    calls to build a new URL.
    * gnu/xml/dom/ls/DomLSParser.java:
    (getInputSource): dito.

Please have a deep long thought about this and tell me whether this is a valid
fix. For me this solves the problem I formerly had, of course.

cu
Robert

[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24249
Index: gnu/xml/aelfred2/SAXDriver.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/xml/aelfred2/SAXDriver.java,v
retrieving revision 1.7
diff -u -r1.7 SAXDriver.java
--- gnu/xml/aelfred2/SAXDriver.java     2 Jul 2005 20:32:15 -0000       1.7
+++ gnu/xml/aelfred2/SAXDriver.java     7 Oct 2005 02:39:21 -0000
@@ -751,7 +751,14 @@
           }
         else
           {
-            return new URL(new URL(baseURI), systemId).toString();
+            URL url = new URL(new URL(baseURI), systemId);
+
+            // Note: The following line contains a workaround for a specific 
behavior
+            // of the URL class where
+            // new URL(new 
URL("file:////foo/baz.xml").toString()).getHost().equals("foo")
+            // would be true although it is technically wrong
+            // (foo is a part of the filename).
+            return url.getProtocol() + "://" + url.getHost() + url.getFile();
           }
       }
     catch (MalformedURLException e)
Index: gnu/xml/dom/ls/DomLSParser.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/xml/dom/ls/DomLSParser.java,v
retrieving revision 1.3
diff -u -r1.3 DomLSParser.java
--- gnu/xml/dom/ls/DomLSParser.java     2 Jul 2005 20:32:16 -0000       1.3
+++ gnu/xml/dom/ls/DomLSParser.java     7 Oct 2005 02:39:21 -0000
@@ -397,7 +397,13 @@
                   new File(baseFile, systemId).toURL();
               }
             in = url.openStream();
-            systemId = url.toString();
+            // Note: The following line contains a workaround for a specific 
behavior
+            // of the URL class where
+            // new URL(new 
URL("file:////foo/baz.xml").toString()).getHost().equals("foo")
+            // would be true although it is technically wrong
+            // (foo is a part of the filename).
+            systemId = url.getProtocol() + "://" + url.getHost() + 
url.getFile();
+
             source = new InputSource(in);
             source.setSystemId(systemId);
           }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]