Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: MODIFIED: util ...

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: MODIFIED: util ...

Author ms
Full name zxcv
Date 2001-05-01 18:34:24 PDT
Message User: ms
  Date: 01/05/01 18:34:24

  Modified: java/org/joist/util TagValidator.java
  Log:
  added ability to add allowed tags to list
  
  Revision Changes Path
  1.7 +32 -6 joist/java/org/joist​/util/TagValidator.j​ava
  
  http://joist.tigris.​org/source/browse/jo​ist/java/org/joist/u​til/TagValidator.jav​a.diff?r1=1.6&r2​=1.7
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: TagValidator.java
  ====================​====================​====================​=======
  RCS file: /usr/local/tigris/da​ta/helm/cvs/reposito​ry/joist/java/org/jo​ist/util/TagValidato​r.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- TagValidator.java 2001/01/25 03:07:59 1.6
  +++ TagValidator.java 2001/05/02 01:34:24 1.7
  @@ -67,7 +67,7 @@
     * @author David C. Pellegrini <A HREF="mailto:davidp@​dataweb-systems.com"​>davidp@dataweb-s​ystems.com</A>​
     * @author Jon S. Stevens <A HREF="mailto:jon@lat​chkey.com">jon@la​tchkey.com</A>​
     * @author Michael Salmon <a href="mailto:ms@coll​ab.net">ms@collab​.net</a>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
     */
   public class TagValidator
   {
  @@ -77,8 +77,8 @@
        "DD","DEL","DFN","DI​V","DL","DT","EM","F​IELDSET","FONT",
        "H1","H2","H3","H4",​"H5","H6","HR","I","​IMG","INS","KBD","LI​",
        "LABEL","LEGEND","LI​NK","MAP","MENU","MU​LTICOL","NOBR","NOFR​AMES","NOSCRIPT",
  - "OL","OPTGROUP","P",​"PARAM","PRE","Q","S​","SAMP","SMALL","SP​ACER","SPAN","STRIKE​",
  - "STRONG","STYLE","SU​B","SUP","TBODY","TD​","TFOOT","TH","THEA​D",
  + "OL","OPTGROUP","P",​"PARAM","PRE","Q","S​","SAMP","SMALL","SP​ACER","SPAN",
  + "STRIKE", "STRONG","STYLE","SU​B","SUP","TBODY","TD​","TFOOT","TH","THEA​D",
        "TR","TT","TABLE","U​","UL","VAR","WBR"};​
   
       static final private String[] attributes =
  @@ -90,6 +90,9 @@
       static final private String middleRegExp = "\\s*)\\s*\\b\\s*(\\s*(\\s*";
       static final private String endRegExp = "\\s*)\\s*(\\s​*=\\s*\"?[^<​>\\s]+\"?\\s*)​?\\s*)*\\s*>"​;
   
  + // to be used from addAllowTags(ArrayList)
  + static private ArrayList allowTags = null;
  +
       static final private String orDelim = "|";
       static final private String lt = "&lt;";
       static final private String gt = "&gt;";
  @@ -195,20 +198,21 @@
       */
       private static String buildRegex()
       {
  + mergeTagLists();
           StringBuffer sb = new StringBuffer();
           sb.append ( frontRegExp );
           boolean firstTime = true;
  - for ( int i=0; i < tags.length; i++ )
  + for ( int i=0; i < allowTags.size(); i++ )
           {
               if (firstTime)
               {
  - sb.append(tags[i]);
  + sb.append((String)al​lowTags.get(i));
                   firstTime = false;
               }
               else
               {
                   sb.append(orDelim);
  - sb.append(tags[i]);
  + sb.append((String)al​lowTags.get(i));
               }
           }
           sb.append ( middleRegExp );
  @@ -371,5 +375,27 @@
       catch (MalformedPerl5PatternException ignored)
       {}
       return unclean;
  + }
  +
  + public static void addAllowTags(ArrayList newTags)
  + {
  + // let npe's pass if given a null list
  + if (allowTags == null && newTags != null)
  + {
  + allowTags = newTags;
  + return;
  + }
  + for (int i = 0; i < newTags.size(); i++)
  + {
  + allowTags.add(newTags.get(i));
  + }
  + }
  +
  + private static void mergeTagLists()
  + {
  + for (int i = 0; i < tags.length; i++)
  + {
  + allowTags.add(tags[i]);
  + }
       }
   }
  
  
  

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@jois​t.tigris.org
For additional commands, e-mail: cvs-help at joist dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: MODIFIED: util ... ms zxcv 2001-05-01 18:34:24 PDT
Messages per page: