You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2019/05/06 08:37:41 UTC

[myfaces] branch master updated: MYFACES-4279

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

tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git


The following commit(s) were added to refs/heads/master by this push:
     new 81ca0e3  MYFACES-4279
81ca0e3 is described below

commit 81ca0e3ee17db602db63f27f7a780a619fe998c4
Author: Thomas Andraschko <ta...@apache.org>
AuthorDate: Mon May 6 10:37:35 2019 +0200

    MYFACES-4279
---
 .../renderkit/html/base/HtmlTextRendererBase.java  | 24 ++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlTextRendererBase.java b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlTextRendererBase.java
index 2bda74b..1c607a0 100644
--- a/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlTextRendererBase.java
+++ b/impl/src/main/java/org/apache/myfaces/renderkit/html/base/HtmlTextRendererBase.java
@@ -325,6 +325,11 @@ public class HtmlTextRendererBase
 
         if (component instanceof UIInput)
         {
+            if (!isValidLength(facesContext, (UIInput)component))
+            {
+                return;
+            }
+
             HtmlRendererUtils.decodeUIInput(facesContext, component);
             if (component instanceof ClientBehaviorHolder && !HtmlRendererUtils.isDisabled(component))
             {
@@ -351,6 +356,25 @@ public class HtmlTextRendererBase
                                                        submittedValue);
     }
 
+    protected boolean isValidLength(FacesContext facesContext, UIInput input)
+    {
+        if (input instanceof HtmlInputText)
+        {
+            int maxlength = ((HtmlInputText)input).getMaxlength();
+            if (maxlength >= 0)
+            {
+                String clientId = input.getClientId(facesContext);
+                String value = facesContext.getExternalContext().getRequestParameterMap().get(clientId);
+                if (value != null && value.length() > maxlength)
+                {
+                    return false;
+                }
+            }
+
+        }
+        return true;
+    }
+    
     /**
      * Returns the HTML type attribute of HTML input element, which is being rendered.
      */