Robert Schuster wrote:
here is probably a fix for PR classpath/24249 [0].

2005-10-07  Robert Schuster  <[EMAIL PROTECTED]>

    * 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);
           }

-1

I think URL should be fixed to return the String it was constructed with in toString. Apart from anything else, where you say "URL is correctly implemented", this is not the case. The formal syntax for file: URLs is "file://" + host + "/" + path, possibly with a drive letter colon replaced by a pipe symbol and where host may be "", e.g.

  file:///var/spool/mail/gubbins
  file://localhost/home/gubbins
  file:///C:/Program%20Files/Microsoft%20Internet%20Explorer
  file:///C|/Windows/system32
  file://BILBO/C$/Windows/system32

corresponding to these system-specific filenames:

  /var/spool/mail/gubbins
  /home/gubbins
  C:\Program Files\Microsoft Internet Explorer
  C:\Windows\system32
  \\BILBO\C$\Windows\system32

See RFC 1738, section 3.10 for the specification.

In the case of bug #24249, the input string was

  file:////foo/baz

which should have caused a MalformedURLException according to RFC 1738, as "" is not a valid directory name.
--
Chris Burdess



_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to