myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manol...@apache.org
Subject svn commit: r546811 - /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
Date Wed, 13 Jun 2007 10:20:33 GMT
Author: manolito
Date: Wed Jun 13 03:20:32 2007
New Revision: 546811

URL: http://svn.apache.org/viewvc?view=rev&rev=546811
Log:
TOMAHAWK-983
TOMAHAWK-1021
(merged from 2.0.6 branch)

Modified:
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java?view=diff&rev=546811&r1=546810&r2=546811
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
(original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlRendererUtils.java
Wed Jun 13 03:20:32 2007
@@ -1113,8 +1113,8 @@
             String scrolling = (String)externalContext.getRequestParameterMap().get(AUTO_SCROLL_PARAM);
             if (scrolling != null && scrolling.length() > 0)
             {
-                String x = "0";
-                String y = "0";
+                int x = 0;
+                int y = 0;
                 int comma = scrolling.indexOf(',');
                 if (comma == -1)
                 {
@@ -1122,10 +1122,21 @@
                 }
                 else
                 {
-                    x = scrolling.substring(0, comma);
-                    if (x.equals("undefined")) x = "0";
-                    y = scrolling.substring(comma + 1);
-                    if (y.equals("undefined")) y = "0";
+                    try {
+                        //we convert to int against XSS vulnerability
+                        x = Integer.parseInt(scrolling.substring(0, comma));
+                    } catch (NumberFormatException e) {
+                        log.warn("Error getting x offset for autoscroll feature. Bad param
value: " + scrolling);
+                        x = 0; //ignore false numbers
+                    }
+
+                    try {
+                        //we convert to int against XSS vulnerability
+                        y = Integer.parseInt(scrolling.substring(comma + 1));
+                    } catch (NumberFormatException e) {
+                        log.warn("Error getting y offset for autoscroll feature. Bad param
value: " + scrolling);
+                        y = 0; //ignore false numbers
+                    }
                 }
                 script.append("window.scrollTo(").append(x).append(",").append(y).append(");\n");
             }
@@ -1563,6 +1574,11 @@
         public ScriptContext append(char c)
         {
             buffer.append(c);
+            return this;
+        }
+
+        public ScriptContext append(int i) {
+            buffer.append(i);
             return this;
         }
 



Mime
View raw message