diff options
| author | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-07 18:22:26 +0000 |
|---|---|---|
| committer | tromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-02-07 18:22:26 +0000 |
| commit | 7ff59ae90b930096347695fb5ed51d87663749da (patch) | |
| tree | 6dc3be85930294202aea5c41b9800414ba213f20 /libjava/classpath/gnu/xml/stream | |
| parent | e911c3bee65890c840bbfa91c0c64b7de448ad99 (diff) | |
| download | ppe42-gcc-7ff59ae90b930096347695fb5ed51d87663749da.tar.gz ppe42-gcc-7ff59ae90b930096347695fb5ed51d87663749da.zip | |
2007-02-07 Chris Burdess <dog@gnu.org>
Fixes PR 30718.
* gnu/xml/dom/ls/SAXEventSink.java: Add public accessor/mutators.
* gnu/xml/transform/XSLURIResolver.java: Add support for custom
SAXSources without a backing URL or stream.
Fixes PR 27710.
* gnu/xml/dom/DomDocumentBuilderFactory.java: Fall back to synchronous
LSParser if implementation does not support asynchronous.
* gnu/xml/stream/XMLParser.java,
gnu/xml/stream/XIncludeFilter.java: Use custom code instead of
java.net.URL to resolve to an an absolute URI, to avoid nonexistent
protocol handler problems.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@121694 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/gnu/xml/stream')
| -rw-r--r-- | libjava/classpath/gnu/xml/stream/XIncludeFilter.java | 13 | ||||
| -rw-r--r-- | libjava/classpath/gnu/xml/stream/XMLParser.java | 56 |
2 files changed, 55 insertions, 14 deletions
diff --git a/libjava/classpath/gnu/xml/stream/XIncludeFilter.java b/libjava/classpath/gnu/xml/stream/XIncludeFilter.java index 7e707820d52..86961faea91 100644 --- a/libjava/classpath/gnu/xml/stream/XIncludeFilter.java +++ b/libjava/classpath/gnu/xml/stream/XIncludeFilter.java @@ -42,7 +42,6 @@ import java.io.InputStreamReader; import java.io.IOException; import java.io.Reader; import java.net.HttpURLConnection; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.HashSet; @@ -122,17 +121,7 @@ class XIncludeFilter boolean expandERefs) { super(reader); - try - { - this.systemId = XMLParser.absolutize(null, systemId); - } - catch (MalformedURLException e) - { - RuntimeException e2 = new RuntimeException("unsupported URL: " + - systemId); - e2.initCause(e); - throw e2; - } + this.systemId = XMLParser.absolutize(null, systemId); this.namespaceAware = namespaceAware; this.validating = validating; this.expandERefs = expandERefs; diff --git a/libjava/classpath/gnu/xml/stream/XMLParser.java b/libjava/classpath/gnu/xml/stream/XMLParser.java index ef3779944c3..663a300f88c 100644 --- a/libjava/classpath/gnu/xml/stream/XMLParser.java +++ b/libjava/classpath/gnu/xml/stream/XMLParser.java @@ -1592,7 +1592,6 @@ public class XMLParser * @param href the (absolute or relative) URL to resolve */ public static String absolutize(String base, String href) - throws MalformedURLException { if (href == null) return null; @@ -1622,7 +1621,60 @@ public class XMLParser if (!base.endsWith("/")) base += "/"; } - return new URL(new URL(base), href).toString(); + // We can't use java.net.URL here to do the parsing, as it searches for + // a protocol handler. A protocol handler may not be registered for the + // URL scheme here. Do it manually. + // + // Set aside scheme and host portion of base URL + String basePrefix = null; + ci = base.indexOf(':'); + if (ci > 1 && isURLScheme(base.substring(0, ci))) + { + if (base.length() > (ci + 3) && + base.charAt(ci + 1) == '/' && + base.charAt(ci + 2) == '/') + { + int si = base.indexOf('/', ci + 3); + if (si == -1) + base = null; + else + { + basePrefix = base.substring(0, si); + base = base.substring(si); + } + } + else + base = null; + } + if (base == null) // unknown or malformed base URL, use href + return href; + if (href.startsWith("/")) // absolute href pathname + return (basePrefix == null) ? href : basePrefix + href; + // relative href pathname + if (!base.endsWith("/")) + { + int lsi = base.lastIndexOf('/'); + if (lsi == -1) + base = "/"; + else + base = base.substring(0, lsi + 1); + } + while (href.startsWith("../") || href.startsWith("./")) + { + if (href.startsWith("../")) + { + // strip last path component from base + int lsi = base.lastIndexOf('/', base.length() - 2); + if (lsi > -1) + base = base.substring(0, lsi + 1); + href = href.substring(3); // strip ../ prefix + } + else + { + href = href.substring(2); // strip ./ prefix + } + } + return (basePrefix == null) ? base + href : basePrefix + base + href; } /** |

