You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2007/02/27 10:16:15 UTC
svn commit: r512185 -
/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java
Author: vhennebert
Date: Tue Feb 27 01:16:14 2007
New Revision: 512185
URL: http://svn.apache.org/viewvc?view=rev&rev=512185
Log:
Add an ending slash to base URLs when they don't have one, in order to better match user expectations.
Submitted by: Adrian Cumiskey (fop-dev AT cumiskey DOT com)
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java?view=diff&rev=512185&r1=512184&r2=512185
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOURIResolver.java Tue Feb 27 01:16:14 2007
@@ -87,7 +87,12 @@
log.error("Could not convert filename to URL: " + mfue.getMessage());
}
} else {
- URL baseURL = toBaseURL(base);
+ URL baseURL = null;
+ try {
+ baseURL = toBaseURL(base);
+ } catch (MalformedURLException mfue) {
+ log.error("Error with base URL \"" + base + "\"): " + mfue.getMessage());
+ }
if (baseURL == null) {
// We don't have a valid baseURL just use the URL as given
try {
@@ -155,7 +160,7 @@
//Note: This is on "debug" level since the caller is supposed to handle this
log.debug("File not found: " + effURL);
} catch (java.io.IOException ioe) {
- log.error("Error with opening URL '" + href + "': " + ioe.getMessage());
+ log.error("Error with opening URL '" + effURL + "': " + ioe.getMessage());
}
return null;
}
@@ -201,15 +206,20 @@
* @param baseURL the base URL
* @returns the base URL as java.net.URL
*/
- private URL toBaseURL(String baseURL) {
- try {
- return new URL(baseURL == null
- ? new java.io.File("").toURL().toExternalForm()
- : baseURL);
- } catch (MalformedURLException mfue) {
- log.error("Error with base URL \"" + baseURL + "\"): " + mfue.getMessage());
+ private URL toBaseURL(String base) throws MalformedURLException {
+ if (base == null) {
+ return new java.io.File("").toURL();
}
- return null;
+ if (!base.endsWith("/")) {
+ // The behavior described by RFC 3986 regarding resolution of relative
+ // references may be misleading for normal users:
+ // file://path/to/resources + myResource.res -> file://path/to/myResource.res
+ // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
+ // We assume that even when the ending slash is missing, users have the second
+ // example in mind
+ base += "/";
+ }
+ return new URL(base);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org