[jboss-cvs] JBossAS SVN: r95627 - in branches/Branch_4_2: varia/src/resources/jmx/html and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Oct 27 15:29:31 EDT 2009


Author: bshim
Date: 2009-10-27 15:29:31 -0400 (Tue, 27 Oct 2009)
New Revision: 95627

Modified:
   branches/Branch_4_2/console/src/resources/webconsole.war/createSnapshot.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitor.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitorSummary.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitor.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitorSummary.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/listMonitors.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/manageSnapshot.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/manageStringThresholdMonitor.jsp
   branches/Branch_4_2/console/src/resources/webconsole.war/manageThresholdMonitor.jsp
   branches/Branch_4_2/varia/src/resources/jmx/html/inspectMBean.jsp
Log:
JBAS-7406 sanitize input before it is returned to the user

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/createSnapshot.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/createSnapshot.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/createSnapshot.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -13,6 +13,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+ 
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>
 <%
    String error = (String)request.getAttribute("error");
    String attribute = request.getParameter("attribute");
@@ -60,22 +78,22 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>"></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>"></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=objectName%>" size="35"></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(objectName)%>" size="35"></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35"></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35"></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>"></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>"></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 </table>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitor.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitor.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitor.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -13,6 +13,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>  
 <%
    MBeanServer mbeanServer = MBeanServerLocator.locateJBoss();
    String error = (String)request.getAttribute("error");
@@ -85,27 +103,27 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>"></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>"></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=objectName%>" size="35"></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(objectName)%>" size="35"></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35"></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35"></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Threshold</b></td>
-    <td><input type="text" name="threshold" size="35" value="<%=threshold%>"></td>
+    <td><input type="text" name="threshold" size="35" value="<%=translateMetaCharacters(threshold)%>"></td>
     <td><i>The value that will trigger an alert when the Comparison Equation is reached for the attribute value</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>"></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>"></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 <tr>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitorSummary.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitorSummary.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/createStringThresholdMonitorSummary.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -13,6 +13,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>  
 <%
    String monitorName = request.getParameter("monitorName");
    if (monitorName == null) monitorName = "";
@@ -70,27 +88,27 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>" readonly></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>" readonly></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=objectName%>" size="35" readonly></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(objectName)%>" size="35" readonly></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35" readonly></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35" readonly></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Threshold</b></td>
-    <td><input type="text" name="threshold" size="35" value="<%=threshold%>" readonly></td>
+    <td><input type="text" name="threshold" size="35" value="<%=translateMetaCharacters(threshold)%>" readonly></td>
     <td><i>The value that will trigger an alert when the Comparison Equation is reached for the attribute value</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>" readonly></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>" readonly></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 <tr>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitor.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitor.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitor.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -13,6 +13,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%> 
 <%
    String error = (String)request.getAttribute("error");
    String monitorName = request.getParameter("monitorName");
@@ -77,27 +95,27 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>"></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>"></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=objectName%>" size="35"></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(objectName)%>" size="35"></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35"></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35"></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Threshold</b></td>
-    <td><input type="text" name="threshold" size="35" value="<%=threshold%>"></td>
+    <td><input type="text" name="threshold" size="35" value="<%=translateMetaCharacters(threshold)%>"></td>
     <td><i>The value that will trigger an alert when the Comparison Equation is reached for the attribute value</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>"></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>"></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 <tr>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitorSummary.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitorSummary.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/createThresholdMonitorSummary.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -13,6 +13,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+ 
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%> 
 <%
    String monitorName = request.getParameter("monitorName");
    if (monitorName == null) monitorName = "";
@@ -68,27 +86,27 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>" readonly></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>" readonly></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=objectName%>" size="35" readonly></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(objectName)%>" size="35" readonly></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35" readonly></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35" readonly></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Threshold</b></td>
-    <td><input type="text" name="threshold" size="35" value="<%=threshold%>" readonly></td>
+    <td><input type="text" name="threshold" size="35" value="<%=translateMetaCharacters(threshold)%>" readonly></td>
     <td><i>The value that will trigger an alert when the Comparison Equation is reached for the attribute value</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>" readonly></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>" readonly></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 <tr>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/listMonitors.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/listMonitors.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/listMonitors.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -14,6 +14,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+ <%!
+
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>
 <%
 try
 {
@@ -100,9 +118,9 @@
 %>
 <tr>
     <td><%=status%></td>
-    <td><font color="<%=color%>"><%=monitorName%></font></td>
-    <td><font color="<%=color%>"><a href="<%=observedMbeanLink%>"><%=observedObject.toString()%></a></font></td>
-    <td><font color="<%=color%>"><%=attribute%></font></td>
+    <td><font color="<%=color%>"><%=translateMetaCharacters(monitorName)%></font></td>
+    <td><font color="<%=color%>"><a href="<%=observedMbeanLink%>"><%=translateMetaCharacters(observedObject.toString())%></a></font></td>
+    <td><font color="<%=color%>"><%=translateMetaCharacters(attribute)%></font></td>
     <td><a href="<%=link%>">manage</a></td>
 </tr>
 <%

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/manageSnapshot.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/manageSnapshot.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/manageSnapshot.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -14,6 +14,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+   
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+   	     return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>
 <%
 try
 {
@@ -67,31 +85,31 @@
    }
 %>
 <form action="ManageSnapshot" method="post">
-<input type="hidden" name="monitorObjectName" value="<%=moname.toString()%>">
+<input type="hidden" name="monitorObjectName" value="<%=translateMetaCharacters(moname.toString())%>">
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>" readonly></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>" readonly></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Monitor's Object Name</b></td>
-    <td><input type="text" name="monitorObjectName" size="35" value="<%=monitorObjectName%>" readonly></td>
+    <td><input type="text" name="monitorObjectName" size="35" value="<%=translateMetaCharacters(monitorObjectName)%>" readonly></td>
     <td><i>The MBean javax.management.ObjectName</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=observedObject.toString()%>" size="35" readonly></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(observedObject.toString())%>" size="35" readonly></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35" readonly></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35" readonly></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>" readonly></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>" readonly></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 </table>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/manageStringThresholdMonitor.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/manageStringThresholdMonitor.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/manageStringThresholdMonitor.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -14,6 +14,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+   	     return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>   
 <%
 try
 {
@@ -78,22 +96,22 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>" readonly></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>" readonly></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Monitor's Object Name</b></td>
-    <td><input type="text" name="monitorObjectName" size="35" value="<%=monitorObjectName%>" readonly></td>
+    <td><input type="text" name="monitorObjectName" size="35" value="<%=translateMetaCharacters(monitorObjectName)%>" readonly></td>
     <td><i>The MBean javax.management.ObjectName</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=observedObject.toString()%>" size="35" readonly></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(observedObject.toString())%>" size="35" readonly></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35" readonly></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35" readonly></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <%
@@ -102,18 +120,18 @@
 %>
 <tr>
     <td><font color="red"><b>Triggered Value</b></font></td>
-    <td><input type="text" name="trigger" value="<%=triggeredValue.toString()%>" size="35" readonly></td>
+    <td><input type="text" name="trigger" value="<%=translateMetaCharacters(triggeredValue.toString())%>" size="35" readonly></td>
     <td><i>The attribute value the triggered the threshold.</i></td>
 </tr>
 <% } %>
 <tr>
     <td><b>Threshold</b></td>
-    <td><input type="text" name="threshold" size="35" value="<%=threshold%>"></td>
+    <td><input type="text" name="threshold" size="35" value="<%=translateMetaCharacters(threshold)%>"></td>
     <td><i>The value that will trigger an alert when the Comparison Equation is reached for the attribute value</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>"></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>"></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 <tr>

Modified: branches/Branch_4_2/console/src/resources/webconsole.war/manageThresholdMonitor.jsp
===================================================================
--- branches/Branch_4_2/console/src/resources/webconsole.war/manageThresholdMonitor.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/console/src/resources/webconsole.war/manageThresholdMonitor.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -14,6 +14,24 @@
  | Distributable under LGPL license.
  | See terms of license at gnu.org.
  +--%>
+<%!
+
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+   	     return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
+%>    
 <%
 try
 {
@@ -78,22 +96,22 @@
 <table cellspacing="2" cellpadding="2" border="0">
 <tr>
     <td><b>Monitor Name</b></td>
-    <td><input type="text" name="monitorName" size="35" value="<%=monitorName%>" readonly></td>
+    <td><input type="text" name="monitorName" size="35" value="<%=translateMetaCharacters(monitorName)%>" readonly></td>
     <td><i>The name of the monitor and how it will be references within web console</i></td>
 </tr>
 <tr>
     <td><b>Monitor's Object Name</b></td>
-    <td><input type="text" name="monitorObjectName" size="35" value="<%=monitorObjectName%>" readonly></td>
+    <td><input type="text" name="monitorObjectName" size="35" value="<%=translateMetaCharacters(monitorObjectName)%>" readonly></td>
     <td><i>The MBean javax.management.ObjectName</i></td>
 </tr>
 <tr>
     <td><b>Object Name</b></td>
-    <td><input type="text" name="objectName" value="<%=observedObject.toString()%>" size="35" readonly></td>
+    <td><input type="text" name="objectName" value="<%=translateMetaCharacters(observedObject.toString())%>" size="35" readonly></td>
     <td><i>The MBean javax.management.ObjectName of the MBean you are monitoring</i></td>
 </tr>
 <tr>
     <td><b>Attribute</b></td>
-    <td><input type="text" name="attribute" value="<%=attribute%>"  size="35" readonly></td>
+    <td><input type="text" name="attribute" value="<%=translateMetaCharacters(attribute)%>"  size="35" readonly></td>
     <td><i>The MBean Attribute you are monitoring</i></td>
 </tr>
 <%
@@ -102,18 +120,18 @@
 %>
 <tr>
     <td><font color="red"><b>Triggered Value</b></font></td>
-    <td><input type="text" name="trigger" value="<%=triggeredValue.toString()%>" size="35" readonly></td>
+    <td><input type="text" name="trigger" value="<%=translateMetaCharacters(triggeredValue.toString())%>" size="35" readonly></td>
     <td><i>The attribute value the triggered the threshold.</i></td>
 </tr>
 <% } %>
 <tr>
     <td><b>Threshold</b></td>
-    <td><input type="text" name="threshold" size="35" value="<%=threshold%>"></td>
+    <td><input type="text" name="threshold" size="35" value="<%=translateMetaCharacters(threshold)%>"></td>
     <td><i>The value that will trigger an alert when the Comparison Equation is reached for the attribute value</i></td>
 </tr>
 <tr>
     <td><b>Time Period</b></td>
-    <td><input type="text" name="period" size="35" value="<%=period%>"></td>
+    <td><input type="text" name="period" size="35" value="<%=translateMetaCharacters(period)%>"></td>
     <td><i>How often should threshold be tested.</i></td>
 </tr>
 <tr>

Modified: branches/Branch_4_2/varia/src/resources/jmx/html/inspectMBean.jsp
===================================================================
--- branches/Branch_4_2/varia/src/resources/jmx/html/inspectMBean.jsp	2009-10-27 19:17:29 UTC (rev 95626)
+++ branches/Branch_4_2/varia/src/resources/jmx/html/inspectMBean.jsp	2009-10-27 19:29:31 UTC (rev 95627)
@@ -22,6 +22,22 @@
       sname = name.replace("\'", "&apos;");
       return sname;
    }
+   
+   /**
+    * Translate HTML tags and single and double quotes.
+    */
+   public String translateMetaCharacters(Object value)
+   {
+      if(value == null) 
+         return null;
+   	  
+      String s = String.valueOf(value);   
+      String sanitizedName = s.replace("<", "&lt;");
+      sanitizedName = sanitizedName.replace(">", "&gt;");
+      sanitizedName = sanitizedName.replace("\"", "&quot;");
+      sanitizedName = sanitizedName.replace("\'", "&apos;");
+      return sanitizedName;
+   }
 %>
 <html>
 <head>
@@ -67,7 +83,8 @@
    while( it.hasNext() )
    {
       String key = (String) it.next();
-      String value = (String) properties.get( key );
+      String value = translateMetaCharacters((String) properties.get( key ));
+      
 %>
       <tr><td></td><td><b><%= key %>: </b></td><td><%= value %></td></tr>
 <%
@@ -155,7 +172,7 @@
             if( attrType.equals("javax.management.ObjectName") )
                avalue = quoteName(avalue);
 %>
-          <input type="text" name="<%= attrName %>" value='<%= avalue %>' <%= readonly %>>
+          <input type="text" name="<%= attrName %>" value='<%= translateMetaCharacters(avalue) %>' <%= readonly %>>
 
 <%
          }




More information about the jboss-cvs-commits mailing list