Skip to content

Commit 8c3aa20

Browse files
authored
Fixed FreeMarker template resolution issue when OFBiz installation or component paths contain spaces (OFBIZ-10434) (#1226)
Updated FlexibleTemplateLoader#getURL() in FreeMarkerWorker to use: `new File(locationUrl.toURI()).exists()` This fixes template lookup failures caused by URL-encoded paths (%20) when OFBiz or component directories contain spaces. Thanks Jacques Le Roux for reporting the issue.
1 parent 0fe65ee commit 8c3aa20

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.Set;
3333
import java.util.TimeZone;
3434
import java.util.stream.Stream;
35-
3635
import jakarta.servlet.ServletContext;
3736
import jakarta.servlet.http.HttpServletRequest;
3837

@@ -557,13 +556,13 @@ protected URL getURL(String name) {
557556
if (name != null && name.startsWith("delegator:")) {
558557
return null; // this is a template stored in the database
559558
}
560-
URL locationUrl = null;
561559
try {
562-
locationUrl = FlexibleLocation.resolveLocation(name);
560+
URL locationUrl = FlexibleLocation.resolveLocation(name);
561+
return locationUrl != null && new File(locationUrl.toURI()).exists() ? locationUrl : null;
563562
} catch (Exception e) {
564563
Debug.logWarning("Unable to locate the template: " + name, MODULE);
565564
}
566-
return locationUrl != null && new File(locationUrl.getFile()).exists() ? locationUrl : null;
565+
return null;
567566
}
568567
}
569568

0 commit comments

Comments
 (0)