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

kusal pushed a commit to branch WW-5336-deprecate-ognltool
in repository https://gitbox.apache.org/repos/asf/struts.git

commit fdf00c1fdc62c2a1096ff41cb89f71bd2ebe625a
Author: Kusal Kithul-Godage <g...@kusal.io>
AuthorDate: Mon Aug 21 19:10:40 2023 +1000

    WW-5336 Deprecate OGNL in template context
---
 core/src/main/java/org/apache/struts2/views/util/ContextUtil.java | 8 +++-----
 core/src/main/resources/struts.vm                                 | 2 +-
 .../java/org/apache/struts2/views/velocity/VelocityManager.java   | 6 +++++-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java 
b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
index f021845d5..97c148f37 100644
--- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
+++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java
@@ -18,12 +18,9 @@
  */
 package org.apache.struts2.views.util;
 
-import com.opensymphony.xwork2.ActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.struts2.StrutsConstants;
 import org.apache.struts2.util.StrutsUtil;
-import org.apache.struts2.views.jsp.ui.OgnlTool;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -50,8 +47,9 @@ public class ContextUtil {
         map.put(SESSION, req.getSession(false));
         map.put(BASE, req.getContextPath());
         map.put(STACK, stack);
-        map.put(OGNL, 
stack.getActionContext().getContainer().getInstance(OgnlTool.class));
-        map.put(STRUTS, new StrutsUtil(stack, req, res));
+        StrutsUtil util = new StrutsUtil(stack, req, res);
+        map.put(STRUTS, util);
+        map.put(OGNL, util); // Deprecated since 6.3.0
 
         ActionInvocation invocation = 
stack.getActionContext().getActionInvocation();
         if (invocation != null) {
diff --git a/core/src/main/resources/struts.vm 
b/core/src/main/resources/struts.vm
index 0b198e990..a92eb70d9 100644
--- a/core/src/main/resources/struts.vm
+++ b/core/src/main/resources/struts.vm
@@ -33,5 +33,5 @@
 #end
 
 #macro(property $object $property)
-$!{ognl.findValue($property, $object)}
+$!{struts.findValue($property, $object)}
 #end
diff --git 
a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
 
b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
index 9ea9d7a7f..2ad8f1eed 100644
--- 
a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
+++ 
b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java
@@ -54,6 +54,8 @@ import java.util.Properties;
 import java.util.Set;
 import java.util.StringTokenizer;
 
+import static org.apache.struts2.views.util.ContextUtil.OGNL;
+
 /**
  * Manages the environment for Velocity result types
  */
@@ -136,7 +138,9 @@ public class VelocityManager {
         for (Map.Entry<String, Object> entry : standardMap.entrySet()) {
             context.put(entry.getKey(), entry.getValue());
         }
-        context.put(STRUTS, new VelocityStrutsUtil(velocityEngine, context, 
stack, req, res));
+        VelocityStrutsUtil util = new VelocityStrutsUtil(velocityEngine, 
context, stack, req, res);
+        context.put(STRUTS, util);
+        context.put(OGNL, util); // Deprecated since 6.3.0
 
         ServletContext ctx = null;
         try {

Reply via email to