[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-commit] r949 - in jetty/trunk: . test-jetty-webapp/src/main/java/com/acme

Author: gwilkins
Date: 2009-09-23 23:53:33 -0400 (Wed, 23 Sep 2009)
New Revision: 949

Modified:
   jetty/trunk/VERSION.txt
   jetty/trunk/test-jetty-webapp/src/main/java/com/acme/CookieDump.java
Log:
fixed XSS issue in demo CometDump servlet

Modified: jetty/trunk/VERSION.txt
===================================================================
--- jetty/trunk/VERSION.txt	2009-09-22 05:57:32 UTC (rev 948)
+++ jetty/trunk/VERSION.txt	2009-09-24 03:53:33 UTC (rev 949)
@@ -7,6 +7,7 @@
  + 289027 deobfuscate HttpClient SSL passwords
  + 289959 Improved ContextDeployer configuration
  + JETTY-1114 unsynchronised WebAppClassloader.getResource(String)
+ + Fixed XSS issue in CookieDump demo servlet.
 
 jetty-7.0.0
  + 289958 StatisticsServlet incorrectly adds StatisticsHandler

Modified: jetty/trunk/test-jetty-webapp/src/main/java/com/acme/CookieDump.java
===================================================================
--- jetty/trunk/test-jetty-webapp/src/main/java/com/acme/CookieDump.java	2009-09-22 05:57:32 UTC (rev 948)
+++ jetty/trunk/test-jetty-webapp/src/main/java/com/acme/CookieDump.java	2009-09-24 03:53:33 UTC (rev 949)
@@ -85,7 +85,7 @@
         
         for (int i=0;cookies!=null && i<cookies.length;i++)
         {
-            out.println("<b>"+cookies[i].getName()+"</b>="+cookies[i].getValue()+"<br/>");
+            out.println("<b>"+deScript(cookies[i].getName())+"</b>="+deScript(cookies[i].getValue())+"<br/>");
         }
         
         out.println("<form action=\""+response.encodeURL(getURI(request))+"\" method=\"post\">"); 
@@ -110,5 +110,16 @@
             uri=request.getRequestURI();
         return uri;
     }
+
+    /* ------------------------------------------------------------ */
+    protected String deScript(String string)
+    {
+        if (string==null)
+            return null;
+        string=string.replace("&", "&amp;");
+        string=string.replace( "<", "&lt;");
+        string=string.replace( ">", "&gt;");
+        return string;
+    }
     
 }