I know this was reported (at least) once before and I couldn't
reproduce it. However, trying to reproduce the XInclude bug (I
couldn't) this morning, I tripped over the

   file://tmp/...

bug where the attempt to access that URI falls over with "unknown host: tmp".

So I dug around a bit.

I (1) consolidated several places where I was attempting to build a
URL from a filename into calls to FileURL.makeURL() and (2) tried more
aggressively in FileURL.makeURL() to make sure that file://path/ never
occurs.

Before I commit these changes, can someone else give them a whirl? If
someone on a Windows box could try too, that'd be swell. If no one
reports back, in a week or so, I'll go ahead and commit the changes.

Index: src/org/apache/xml/resolver/readers/TextCatalogReader.java
===================================================================
--- src/org/apache/xml/resolver/readers/TextCatalogReader.java	(revision 394065)
+++ src/org/apache/xml/resolver/readers/TextCatalogReader.java	(working copy)
@@ -31,6 +31,7 @@
 import org.apache.xml.resolver.CatalogEntry;
 import org.apache.xml.resolver.CatalogException;
 import org.apache.xml.resolver.readers.CatalogReader;
+import org.apache.xml.resolver.helpers.FileURL;
 
 /**
  * Parses plain text Catalog files.
@@ -96,7 +97,7 @@
     try {
       catURL = new URL(fileUrl);
     } catch (MalformedURLException e) {
-      catURL = new URL("file:///" + fileUrl);
+	catURL = FileURL.makeURL(fileUrl);
     }
 
     URLConnection urlCon = catURL.openConnection();
Index: src/org/apache/xml/resolver/readers/SAXCatalogReader.java
===================================================================
--- src/org/apache/xml/resolver/readers/SAXCatalogReader.java	(revision 394077)
+++ src/org/apache/xml/resolver/readers/SAXCatalogReader.java	(working copy)
@@ -47,6 +47,7 @@
 import org.apache.xml.resolver.CatalogException;
 import org.apache.xml.resolver.readers.CatalogReader;
 import org.apache.xml.resolver.helpers.Debug;
+import org.apache.xml.resolver.helpers.FileURL;
 
 /**
  * A SAX-based CatalogReader.
@@ -202,7 +203,7 @@
     try {
       url = new URL(fileUrl);
     } catch (MalformedURLException e) {
-      url = new URL("file:///" + fileUrl);
+	url = FileURL.makeURL(fileUrl);
     }
 
     debug = catalog.getCatalogManager().debug;
Index: src/org/apache/xml/resolver/Catalog.java
===================================================================
--- src/org/apache/xml/resolver/Catalog.java	(revision 394093)
+++ src/org/apache/xml/resolver/Catalog.java	(working copy)
@@ -830,7 +830,7 @@
       base = new URL(catalogCwd, fixSlashes(fileName));
     } catch (MalformedURLException e) {
       try {
-	base = new URL("file:" + fixSlashes(fileName));
+	  base = FileURL.makeURL(fixSlashes(fileName));
       } catch (MalformedURLException e2) {
 	catalogManager.debug.message(1, "Malformed URL on catalog filename",
 		      fixSlashes(fileName));
@@ -916,7 +916,7 @@
 	newbase = new URL(base, value);
       } catch (MalformedURLException e) {
 	try {
-	  newbase = new URL("file:" + value);
+	    newbase = FileURL.makeURL(value);
 	} catch (MalformedURLException e2) {
 	  catalogManager.debug.message(1, "Malformed URL on base", value);
 	  newbase = null;
Index: src/org/apache/xml/resolver/helpers/FileURL.java
===================================================================
--- src/org/apache/xml/resolver/helpers/FileURL.java	(revision 394093)
+++ src/org/apache/xml/resolver/helpers/FileURL.java	(working copy)
@@ -76,10 +76,20 @@
     String userdir = System.getProperty("user.dir");
     userdir = userdir.replace('\\', '/');
 
+    URL file = null;
+
+    String sep = "/";
     if (userdir.endsWith("/")) {
-      return new URL("file:///" + userdir + pathname);
+	sep = "";
+    }
+
+    if (userdir.startsWith("/")) {
+      file = new URL("file://" + userdir + sep + pathname);
     } else {
-      return new URL("file:///" + userdir + "/" + pathname);
+      file = new URL("file:///" + userdir + sep + pathname);
     }
+
+    return file;
+
   }
 }
Index: src/org/apache/xml/resolver/apps/resolver.java
===================================================================
--- src/org/apache/xml/resolver/apps/resolver.java	(revision 394093)
+++ src/org/apache/xml/resolver/apps/resolver.java	(working copy)
@@ -208,7 +208,7 @@
 	systemId = sysid.toString();
       } catch (MalformedURLException e) {
 	try {
-	  sysid = new URL("file:///" + systemId);
+	    sysid = FileURL.makeURL(systemId);
 	} catch (MalformedURLException e2) {
 	  debug.message(1, "Malformed URL on system id", systemId);
 	}
                                        Be seeing you,
                                          norm

-- 
[EMAIL PROTECTED] / XML Standards Architect / Sun Microsystems, Inc.
NOTICE: This email message is for the sole use of the intended
recipient(s) and may contain confidential and privileged information.
Any unauthorized review, use, disclosure or distribution is prohibited.
If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.

Attachment: pgpj8G47oj08f.pgp
Description: PGP signature

Reply via email to