From a19fc7534d33c24a92ae88bbf172fc99327cf792 Mon Sep 17 00:00:00 2001 From: Chris Bowditch Date: Thu, 7 May 2009 15:08:30 +0000 Subject: [PATCH] bug fix: allow back slashes for file URLs as they are commonly used in Windows git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@772672 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/apps/FOURIResolver.java | 2 ++ test/java/org/apache/fop/config/FOURIResolverTestCase.java | 1 + test/java/org/apache/fop/config/UserConfigTestSuite.java | 1 + 3 files changed, 4 insertions(+) diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java index f96711d31..c7d564ea3 100644 --- a/src/java/org/apache/fop/apps/FOURIResolver.java +++ b/src/java/org/apache/fop/apps/FOURIResolver.java @@ -68,6 +68,8 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * @throws MalformedURLException if there's a problem with a file URL */ public String checkBaseURL(String base) throws MalformedURLException { + // replace back slash with forward slash to ensure windows file:/// URLS are supported + base = base.replace('\\', '/'); if (!base.endsWith("/")) { // The behavior described by RFC 3986 regarding resolution of relative // references may be misleading for normal users: diff --git a/test/java/org/apache/fop/config/FOURIResolverTestCase.java b/test/java/org/apache/fop/config/FOURIResolverTestCase.java index e6f8db712..e0f6d7f81 100644 --- a/test/java/org/apache/fop/config/FOURIResolverTestCase.java +++ b/test/java/org/apache/fop/config/FOURIResolverTestCase.java @@ -39,6 +39,7 @@ public class FOURIResolverTestCase extends TestCase { System.out.println(resolver.checkBaseURL("./test/config")); System.out.println(resolver.checkBaseURL("file:test/config")); System.out.println(resolver.checkBaseURL("fantasy:myconfig")); + System.out.println(resolver.checkBaseURL("file:test\\config\\")); try { resolver.checkBaseURL("./doesnotexist"); fail("Expected an exception for a inexistent base directory"); diff --git a/test/java/org/apache/fop/config/UserConfigTestSuite.java b/test/java/org/apache/fop/config/UserConfigTestSuite.java index f933a0342..168d87d51 100644 --- a/test/java/org/apache/fop/config/UserConfigTestSuite.java +++ b/test/java/org/apache/fop/config/UserConfigTestSuite.java @@ -45,6 +45,7 @@ public class UserConfigTestSuite { suite.addTest(new TestSuite(FontsDirectoryRecursiveTestCase.class)); suite.addTest(new TestSuite(FontsAutoDetectTestCase.class)); suite.addTest(new TestSuite(FontsSubstitutionTestCase.class)); + suite.addTest(new TestSuite(FOURIResolverTestCase.class)); //$JUnit-END$ return suite; } -- 2.39.5