tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amy...@apache.org
Subject cvs commit: jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans StandardServerMBean.java
Date Thu, 16 May 2002 20:18:49 GMT
amyroh      02/05/16 13:18:49

  Modified:    catalina/src/share/org/apache/catalina/mbeans
                        StandardServerMBean.java
  Log:
  Add xml encoding of special characters '>', '<', ''', '"', '&' when writing out
to
  server.xml.  xml parser exception was thrown when a user enters these
  chracters and save in admin tool before.
  
  Revision  Changes    Path
  1.22      +34 -5     jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java
  
  Index: StandardServerMBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- StandardServerMBean.java	3 May 2002 23:19:37 -0000	1.21
  +++ StandardServerMBean.java	16 May 2002 20:18:49 -0000	1.22
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v
1.21 2002/05/03 23:19:37 craigmcc Exp $
  - * $Revision: 1.21 $
  - * $Date: 2002/05/03 23:19:37 $
  + * $Header: /home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/mbeans/StandardServerMBean.java,v
1.22 2002/05/16 20:18:49 amyroh Exp $
  + * $Revision: 1.22 $
  + * $Date: 2002/05/16 20:18:49 $
    *
    * ====================================================================
    *
  @@ -123,7 +123,7 @@
    * <code>org.apache.catalina.core.StandardServer</code> component.</p>
    *
    * @author Amy Roh
  - * @version $Revision: 1.21 $ $Date: 2002/05/03 23:19:37 $
  + * @version $Revision: 1.22 $ $Date: 2002/05/16 20:18:49 $
    */
   
   public class StandardServerMBean extends BaseModelMBean {
  @@ -333,6 +333,34 @@
       // -------------------------------------------------------- Private Methods
   
   
  +    /** Given a string, this method replaces all occurrences of
  +     *  '<', '>', '&', and '"'.
  +    */
  +
  +    private String convertStr(String input) {
  +
  +        StringBuffer filtered = new StringBuffer(input.length());
  +        char c;
  +        for(int i=0; i<input.length(); i++) {
  +            c = input.charAt(i);
  +            if (c == '<') {
  +                filtered.append("&lt;");
  +            } else if (c == '>') {
  +                filtered.append("&gt;");
  +            } else if (c == '\'') {
  +                filtered.append("&apos;");
  +            } else if (c == '"') {
  +                filtered.append("&quot;");
  +            } else if (c == '&') {
  +                filtered.append("&amp;");
  +            } else {
  +                filtered.append(c);
  +            }
  +        }
  +            return(filtered.toString());
  +    } 
  +
  +
       /**
        * Is this an instance of the default <code>Loader</code> configuration,
        * with all-default properties?
  @@ -509,7 +537,8 @@
               writer.print(' ');
               writer.print(descriptors[i].getName());
               writer.print("=\"");
  -            writer.print((String) value);
  +            String strValue = convertStr((String) value);
  +            writer.print(strValue);
               writer.print("\"");
           }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message