marc        00/02/02 11:26:04

  Modified:    info/css-security encoding_examples.html
  Log:
  Sigh.  The Java code is GPLed, so I am removing it.
  
  Revision  Changes    Path
  1.4       +0 -44     apache-site/info/css-security/encoding_examples.html
  
  Index: encoding_examples.html
  ===================================================================
  RCS file: 
/export/home/cvs/apache-site/info/css-security/encoding_examples.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- encoding_examples.html    2000/02/02 19:17:41     1.3
  +++ encoding_examples.html    2000/02/02 19:26:03     1.4
  @@ -163,49 +163,5 @@
   http://stein.cshl.org/WWW/software/CGI/</A> for more details on what
   this module can do.
   
  -<H2>Java Example:</H2>
  -
  -Unfortunately, Java does not include a standard method for entity
  -encoding data.  One possible method, taken from the <A
  -HREF="http://www.bitmechanic.com/projects/gsp/";>GSP</A> code, is:
  -
  -<PRE>
  -
  -public static String escapeValue(String str) {  
  -    str = replace(str, '&amp;', "&amp;amp;");
  -    str = replace(str, '"', "&amp;quot;");
  -    str = replace(str, '&lt;', "&amp;lt;");
  -    str = replace(str, '&gt;', "&amp;gt;");
  -    return str;
  -}   
  -
  -public static String replace(String str, char ch, String replace) {  
  -    int pos = str.indexOf(ch);
  -    if(pos == -1) return str;
  -    StringBuffer buff = new StringBuffer(str.length() + 32);
  -    int start = 0;
  -    while(pos != -1 &amp;&amp; start &lt; str.length()) {
  -        buff.append(str.substring(start, pos));
  -        buff.append(replace);
  -
  -        start = pos + 1;
  -        if(start &lt; str.length()) pos = str.indexOf(ch, start);
  -    }   
  -    if(start &lt; str.length()) buff.append(str.substring(start));
  -    return buff.toString();
  -}   
  -
  -</PRE>
  -
  -You would use this in a manner such as:
  - 
  -<PRE>
  -String Text = "foo&lt;b&gt;bar";  
  -String URL = "foo&lt;b&gt;bar.html";  
  -    
  -System.out.println(escapeValue(Text));
  -System.out.println(java.net.URLEncoder.encode(URL));
  -</PRE>
  -
   </BODY>
   </HTML>
  
  
  

Reply via email to