incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awi...@apache.org
Subject svn commit: r420024 - in /incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main: java/org/apache/myfaces/adfinternal/convert/ java/org/apache/myfaces/adfinternal/validator/ javascript/META-INF/adf/jsLibs/
Date Sat, 08 Jul 2006 00:37:18 GMT
Author: awiner
Date: Fri Jul  7 17:37:17 2006
New Revision: 420024

URL: http://svn.apache.org/viewvc?rev=420024&view=rev
Log:
Resolve issues with proper JS escaping of error messages, esp. with apostrophes.  This should
resolve at least parts of ADFFACES-44 and ADFFACES-46.

Modified:
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ColorConverter.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConverterUtils.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/DateTimeConverter.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/InternalClientConverter.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/ByteLengthValidator.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/DateTimeRangeValidator.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/InternalClientValidator.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/LongRangeValidator.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/RegExpValidator.java
    incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ColorConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ColorConverter.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ColorConverter.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ColorConverter.java
Fri Jul  7 17:37:17 2006
@@ -44,7 +44,7 @@
     FacesContext context,
     UIComponent component)
   {
-    return _getEscapedJsConvertMessageDetail(context);
+    return _getConvertMessageDetail(context);
   }
 
   public String getClientScript(FacesContext context, UIComponent component)
@@ -226,7 +226,7 @@
     }
   }
 
-  private String _getEscapedJsConvertMessageDetail(FacesContext context)
+  private String _getConvertMessageDetail(FacesContext context)
   {
     String convMsgDet = getConvertMessageDetail();
 
@@ -245,9 +245,8 @@
     convMsgDet = MessageFactory.getMessage(context, CONVERT_MESSAGE_ID,
                                            convMsgDet, params).getDetail();
 
-    String msg = MessageUtils.createErrorAlertMessage(context, label,
-                                                      convMsgDet);
-    return XhtmlUtils.escapeJS(msg);
+    return MessageUtils.createErrorAlertMessage(context, label,
+                                                convMsgDet);
   }
 
   private static final ADFLogger _LOG = ADFLogger.createADFLogger(ColorConverter.class);

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConverterUtils.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConverterUtils.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConverterUtils.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/ConverterUtils.java
Fri Jul  7 17:37:17 2006
@@ -183,10 +183,9 @@
    String msgId)
   {
     FacesMessage convertMessage = MessageFactory.getMessage(context, msgId);
-    String m = MessageUtils.createErrorAlertMessage(context,
-                                                    component,
-                                                    convertMessage.getDetail());
-    return XhtmlLafUtils.escapeJS(m);
+    return MessageUtils.createErrorAlertMessage(context,
+                                                component,
+                                                convertMessage.getDetail());
   }
 
   public static String getClientValidation(

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/DateTimeConverter.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/DateTimeConverter.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/DateTimeConverter.java
Fri Jul  7 17:37:17 2006
@@ -246,9 +246,9 @@
     Object[] params = new Object[] {label, "{1}", getExample(context)};
     String msg = getParseErrorMessage(context, component,
                                       pattern, params).getDetail();
-    return XhtmlUtils.escapeJS(MessageUtils.createErrorAlertMessage(context,
-                                                                       label,
-                                                                       msg));
+    return MessageUtils.createErrorAlertMessage(context,
+                                                label,
+                                                msg);
   }
 
    /**

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/InternalClientConverter.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/InternalClientConverter.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/InternalClientConverter.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/convert/InternalClientConverter.java
Fri Jul  7 17:37:17 2006
@@ -34,7 +34,8 @@
    UIComponent component); 
   
   /**
-   * Called to retrieve the format to display a conversion error
+   * Called to retrieve the format to display a conversion error.
+   * This method should not return a value that is Javascript-escaped.
    */
   public String getClientConversionFormat(
    FacesContext context,

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/ByteLengthValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/ByteLengthValidator.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/ByteLengthValidator.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/ByteLengthValidator.java
Fri Jul  7 17:37:17 2006
@@ -78,7 +78,7 @@
     UIComponent component
     )
   {
-    return _getEscapedJsMaxiumMessageDetail(context);
+    return _getEscapedJsMaximumMessageDetail(context);
   }
 
   /**
@@ -135,14 +135,14 @@
     }
 
     String lengthFailedMessage
-      = _getEscapedJsMaxiumMessageDetail(context);
+      = _getEscapedJsMaximumMessageDetail(context);
 
     String maxLength = String.valueOf(getMaximum());
 
     constr.append(maxLength);
 
     constr.append(",{LF:'");
-    constr.append(lengthFailedMessage);
+    constr.append(XhtmlLafUtils.escapeJS(lengthFailedMessage));
     constr.append( "'})");
 
     return constr.toString();
@@ -183,7 +183,7 @@
     return _UNSUPPORTED_TYPE;
   }
 
-  private String _getEscapedJsMaxiumMessageDetail(
+  private String _getEscapedJsMaximumMessageDetail(
     FacesContext context)
   {
     String maxMsgDetail = getMaximumMessageDetail();
@@ -199,10 +199,8 @@
                                   params).getDetail();
 
 
-    detailMsg = MessageUtils.createErrorAlertMessage(context, label,
+    return MessageUtils.createErrorAlertMessage(context, label,
                                                      detailMsg);
-
-    return XhtmlLafUtils.escapeJS(detailMsg);
   }
 
 

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/DateTimeRangeValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/DateTimeRangeValidator.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/DateTimeRangeValidator.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/DateTimeRangeValidator.java
Fri Jul  7 17:37:17 2006
@@ -13,34 +13,34 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-package org.apache.myfaces.adfinternal.validator;
-import java.util.Date;
-
-import javax.faces.validator.ValidatorException;
-import javax.faces.context.FacesContext;
-import javax.faces.component.UIComponent;
-
-import org.apache.myfaces.adfinternal.convert.GenericConverterFactory;
-
-public class DateTimeRangeValidator extends org.apache.myfaces.adf.validator.DateTimeRangeValidator
-{
-  public DateTimeRangeValidator()
-  {
-  }
-
-  public void validate(
-    FacesContext context,
-    UIComponent  component,
-    Object       value) throws ValidatorException
-  {
-    if (value == null)
-      return;
-    
-    if (!(value instanceof Date))
-    {
-      GenericConverterFactory fac = GenericConverterFactory.getCurrentInstance();
-      value = fac.convert(value, Date.class);
-    }
-    super.validate(context, component, value);
-  }
-}
+package org.apache.myfaces.adfinternal.validator;
+import java.util.Date;
+
+import javax.faces.validator.ValidatorException;
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIComponent;
+
+import org.apache.myfaces.adfinternal.convert.GenericConverterFactory;
+
+public class DateTimeRangeValidator extends org.apache.myfaces.adf.validator.DateTimeRangeValidator
+{
+  public DateTimeRangeValidator()
+  {
+  }
+
+  public void validate(
+    FacesContext context,
+    UIComponent  component,
+    Object       value) throws ValidatorException
+  {
+    if (value == null)
+      return;
+    
+    if (!(value instanceof Date))
+    {
+      GenericConverterFactory fac = GenericConverterFactory.getCurrentInstance();
+      value = fac.convert(value, Date.class);
+    }
+    super.validate(context, component, value);
+  }
+}

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/InternalClientValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/InternalClientValidator.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/InternalClientValidator.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/InternalClientValidator.java
Fri Jul  7 17:37:17 2006
@@ -35,6 +35,7 @@
   
   /**
    * Called to retrieve the format to display a validation error
+   * This method should not return a value that is Javascript-escaped.
    */
   public String getClientValidationFormat(
    FacesContext context,

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/LongRangeValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/LongRangeValidator.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/LongRangeValidator.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/LongRangeValidator.java
Fri Jul  7 17:37:17 2006
@@ -49,7 +49,7 @@
     {
       super.validate(context, component, value);
     }
-    catch(ValidatorException ve)
+    catch (ValidatorException ve)
     {
          
       Object label = component.getAttributes().get("label");
@@ -85,10 +85,7 @@
       {
         throw ve;
       }
-  
-
     }     
-    
   }
 
   public String getLibKey(
@@ -159,9 +156,9 @@
    */
   public void setMaximum(long maximum)
   {
-      super.setMaximum(maximum);
-      _maximumSet = true;
-
+    super.setMaximum(maximum);
+    _maximumSet = true;
+    
   }
 
   /**
@@ -172,32 +169,31 @@
    */
   public void setMinimum(long minimum)
   {
-      super.setMinimum(minimum);
-      _minimumSet = true;
-
+    super.setMinimum(minimum);
+    _minimumSet = true;
   }
 
-  public Object saveState(FacesContext context) {
-
-      Object values[] = new Object[2];
-      Object clientValues[] = new Object[2];
-
-      clientValues[0] = _maximumSet ? Boolean.TRUE : Boolean.FALSE;
-      clientValues[1] = _minimumSet ? Boolean.TRUE : Boolean.FALSE;
-
-      values[0] = super.saveState(context);
-      values[1] = clientValues;
-      return (values);
-
+  public Object saveState(FacesContext context)
+  {
+    Object values[] = new Object[2];
+    Object clientValues[] = new Object[2];
+    
+    clientValues[0] = _maximumSet ? Boolean.TRUE : Boolean.FALSE;
+    clientValues[1] = _minimumSet ? Boolean.TRUE : Boolean.FALSE;
+    
+    values[0] = super.saveState(context);
+    values[1] = clientValues;
+    return (values);
   }
 
 
-  public void restoreState(FacesContext context, Object state) {
-      Object values[] = (Object[]) state;
-      super.restoreState(context, values[0]);
-      Object clientValues[] = (Object[])values[1];
-      _maximumSet = ((Boolean) clientValues[0]).booleanValue();
-      _minimumSet = ((Boolean) clientValues[1]).booleanValue();
+  public void restoreState(FacesContext context, Object state)
+  {
+    Object values[] = (Object[]) state;
+    super.restoreState(context, values[0]);
+    Object clientValues[] = (Object[])values[1];
+    _maximumSet = ((Boolean) clientValues[0]).booleanValue();
+    _minimumSet = ((Boolean) clientValues[1]).booleanValue();
   }
 
 

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/RegExpValidator.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/RegExpValidator.java?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/RegExpValidator.java
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/java/org/apache/myfaces/adfinternal/validator/RegExpValidator.java
Fri Jul  7 17:37:17 2006
@@ -68,7 +68,8 @@
   {
 
     String jsPattern = XhtmlUtils.escapeJS(getPattern());
-    String esNoMatchMsgPattern = _getEscapedJsNoMatchMessageDetail(context);
+    String esNoMatchMsgPattern = XhtmlUtils.escapeJS(
+                  _getNoMatchMessageDetail(context));
 
 
     StringBuffer outBuffer = new StringBuffer(28
@@ -128,10 +129,10 @@
      * @todo Think it's worth to cache it here and then blow that away once
      * this method gets called. The best would be get rid of this method contract
      */
-    return _getEscapedJsNoMatchMessageDetail(context);
+    return _getNoMatchMessageDetail(context);
   }
 
-  private String _getEscapedJsNoMatchMessageDetail(
+  private String _getNoMatchMessageDetail(
     FacesContext context)
   {
     String noMatchMsg = getNoMatchMessageDetatil();
@@ -143,11 +144,10 @@
                                   RegExpValidator.NO_MATCH_MESSAGE_ID,
                                   noMatchMsg,
                                   params).getDetail();
-    noMatchDetMsg = MessageUtils.createErrorAlertMessage(context, label,
-                                                         noMatchDetMsg);
-    return XhtmlUtils.escapeJS(noMatchDetMsg);
+    return MessageUtils.createErrorAlertMessage(context, label,
+                                                noMatchDetMsg);
   }
 
-  private static final ADFLogger _LOG  = ADFLogger.createADFLogger(RegExpValidator.class);
-
+  private static final ADFLogger _LOG  = ADFLogger.createADFLogger(
+     RegExpValidator.class);
 }

Modified: incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?rev=420024&r1=420023&r2=420024&view=diff
==============================================================================
--- incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
(original)
+++ incubator/adffaces/trunk/adf-faces/adf-faces-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
Fri Jul  7 17:37:17 2006
@@ -2895,7 +2895,10 @@
     }
  }
 
-  return currString;
+  // And now take any doubled-up single quotes down to one,
+  // to handle escaping
+  var twoSingleQuotes = /''/g;
+  return currString.replace(twoSingleQuotes, "'");
 }
 
 /**



Mime
View raw message