Skip to content

Commit db59cb5

Browse files
committed
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 906bdb7 commit db59cb5

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
@@ -35,7 +35,6 @@
3535

3636
import javax.servlet.ServletContext;
3737
import javax.servlet.http.HttpServletRequest;
38-
3938
import org.apache.ofbiz.base.component.ComponentConfig;
4039
import org.apache.ofbiz.base.location.FlexibleLocation;
4140
import org.apache.ofbiz.base.util.Debug;
@@ -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)