This is an automated email from the ASF dual-hosted git repository.

dixitdeepak pushed a commit to branch release24.09
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/release24.09 by this push:
     new db59cb5671 Fixed FreeMarker template resolution issue when OFBiz 
installation or component paths contain spaces (OFBIZ-10434) (#1226)
db59cb5671 is described below

commit db59cb5671bcffa60430daeda79349a5b5a8c2a8
Author: Deepak Dixit <[email protected]>
AuthorDate: Tue May 19 12:08:25 2026 +0530

    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.
---
 .../java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java
 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java
index 548e9dcf81..61fa33b0a6 100644
--- 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java
+++ 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/FreeMarkerWorker.java
@@ -35,7 +35,6 @@ import java.util.stream.Stream;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServletRequest;
-
 import org.apache.ofbiz.base.component.ComponentConfig;
 import org.apache.ofbiz.base.location.FlexibleLocation;
 import org.apache.ofbiz.base.util.Debug;
@@ -557,13 +556,13 @@ public final class FreeMarkerWorker {
             if (name != null && name.startsWith("delegator:")) {
                 return null; // this is a template stored in the database
             }
-            URL locationUrl = null;
             try {
-                locationUrl = FlexibleLocation.resolveLocation(name);
+                URL locationUrl = FlexibleLocation.resolveLocation(name);
+                return locationUrl != null && new 
File(locationUrl.toURI()).exists() ? locationUrl : null;
             } catch (Exception e) {
                 Debug.logWarning("Unable to locate the template: " + name, 
MODULE);
             }
-            return locationUrl != null && new 
File(locationUrl.getFile()).exists() ? locationUrl : null;
+            return null;
         }
     }
 

Reply via email to