You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ni...@apache.org on 2005/08/30 05:58:03 UTC

svn commit: r264694 - in /struts/core/trunk/src/share/org/apache/struts: action/ActionServlet.java config/MessageResourcesConfig.java util/MessageResources.java util/MessageResourcesFactory.java

Author: niallp
Date: Mon Aug 29 20:57:50 2005
New Revision: 264694

URL: http://svn.apache.org/viewcvs?rev=264694&view=rev
Log:
Port to Struts 1.3.x
Bug 32584 - Provide config option to turn off MessageResources escape processing as requested by Tomasz Bech.
Also inject MessageResourcesConfig into the MessageResourcesFactory.Merge changes for

Modified:
    struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java
    struts/core/trunk/src/share/org/apache/struts/config/MessageResourcesConfig.java
    struts/core/trunk/src/share/org/apache/struts/util/MessageResources.java
    struts/core/trunk/src/share/org/apache/struts/util/MessageResourcesFactory.java

Modified: struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java
URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java?rev=264694&r1=264693&r2=264694&view=diff
==============================================================================
--- struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java (original)
+++ struts/core/trunk/src/share/org/apache/struts/action/ActionServlet.java Mon Aug 29 20:57:50 2005
@@ -1537,10 +1537,12 @@
             MessageResourcesFactory.setFactoryClass(factory);
             MessageResourcesFactory factoryObject =
                 MessageResourcesFactory.createFactory();
+            factoryObject.setConfig(mrcs[i]);
 
             MessageResources resources =
                 factoryObject.createResources(mrcs[i].getParameter());
             resources.setReturnNull(mrcs[i].getNull());
+            resources.setEscape(mrcs[i].isEscape());
             getServletContext().setAttribute(
                 mrcs[i].getKey() + config.getPrefix(),
                 resources);

Modified: struts/core/trunk/src/share/org/apache/struts/config/MessageResourcesConfig.java
URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/config/MessageResourcesConfig.java?rev=264694&r1=264693&r2=264694&view=diff
==============================================================================
--- struts/core/trunk/src/share/org/apache/struts/config/MessageResourcesConfig.java (original)
+++ struts/core/trunk/src/share/org/apache/struts/config/MessageResourcesConfig.java Mon Aug 29 20:57:50 2005
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -91,6 +91,31 @@
         this.nullValue = nullValue;
     }
 
+    /**
+     * Indicates whether 'escape processing' should be performed on
+     * the error message string.
+     */
+    private boolean escape = true;
+
+    /**
+     * Indicates whether 'escape processing' should be performed on
+     * the error message string.
+     *
+     * @since Struts 1.2.8
+     */
+    public boolean isEscape() {
+        return escape;
+    }
+
+    /**
+     * Set whether 'escape processing' should be performed on
+     * the error message string.
+     *
+     * @since Struts 1.2.8
+     */
+    public void setEscape(boolean escape) {
+        this.escape = escape;
+    }
 
     /**
      * Parameter that is passed to the <code>createResources()</code> method
@@ -122,6 +147,8 @@
         sb.append(this.factory);
         sb.append(",null=");
         sb.append(this.nullValue);
+        sb.append(",escape=");
+        sb.append(this.escape);
         sb.append(",parameter=");
         sb.append(this.parameter);
         sb.append("]");

Modified: struts/core/trunk/src/share/org/apache/struts/util/MessageResources.java
URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/util/MessageResources.java?rev=264694&r1=264693&r2=264694&view=diff
==============================================================================
--- struts/core/trunk/src/share/org/apache/struts/util/MessageResources.java (original)
+++ struts/core/trunk/src/share/org/apache/struts/util/MessageResources.java Mon Aug 29 20:57:50 2005
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,6 +118,32 @@
         this.returnNull = returnNull;
     }
 
+    /**
+     * Indicates whether 'escape processing' should be performed on
+     * the error message string.
+     */
+    private boolean escape = true;
+
+    /**
+     * Indicates whether 'escape processing' should be performed on
+     * the error message string.
+     *
+     * @since Struts 1.2.8
+     */
+    public boolean isEscape() {
+        return escape;
+    }
+
+    /**
+     * Set whether 'escape processing' should be performed on
+     * the error message string.
+     *
+     * @since Struts 1.2.8
+     */
+    public void setEscape(boolean escape) {
+        this.escape = escape;
+    }
+
     // ----------------------------------------------------------- Constructors
 
     /**
@@ -414,6 +440,10 @@
      * @param string The string to be escaped
      */
     protected String escape(String string) {
+
+        if (!isEscape()) {
+            return string;
+        }
 
         if ((string == null) || (string.indexOf('\'') < 0)) {
             return string;

Modified: struts/core/trunk/src/share/org/apache/struts/util/MessageResourcesFactory.java
URL: http://svn.apache.org/viewcvs/struts/core/trunk/src/share/org/apache/struts/util/MessageResourcesFactory.java?rev=264694&r1=264693&r2=264694&view=diff
==============================================================================
--- struts/core/trunk/src/share/org/apache/struts/util/MessageResourcesFactory.java (original)
+++ struts/core/trunk/src/share/org/apache/struts/util/MessageResourcesFactory.java Mon Aug 29 20:57:50 2005
@@ -1,7 +1,7 @@
 /*
  * $Id$
  *
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
 import java.io.Serializable;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.struts.config.MessageResourcesConfig;
 
 
 /**
@@ -47,6 +48,28 @@
 
     // ---------------------------------------------------- Instance Properties
 
+    /**
+     * Configuration information for Message Resources.
+     */
+    protected MessageResourcesConfig config;
+
+    /**
+     * Set the configuration information for Message Resources.
+     *
+     * @since Struts 1.2.8
+     */
+    public MessageResourcesConfig getConfig() {
+        return config;
+    }
+
+    /**
+     * Return the configuration information for Message Resources.
+     *
+     * @since Struts 1.2.8
+     */
+    public void setConfig(MessageResourcesConfig config) {
+        this.config = config;
+    }
 
     /**
      * The "return null" property value to which newly created



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org