Author: j16sdiz
Date: 2008-09-07 14:27:36 +0000 (Sun, 07 Sep 2008)
New Revision: 22528

Modified:
   trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
generic

Modified: trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java       
2008-09-07 14:09:06 UTC (rev 22527)
+++ trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java       
2008-09-07 14:27:36 UTC (rev 22528)
@@ -43,7 +43,8 @@
        private static boolean deleteWierdStuff = true;
        private static boolean deleteErrors = true;

-       public Bucket readFilter(Bucket bucket, BucketFactory bf, String 
charset, HashMap otherParams, FilterCallback cb) throws DataFilterException, 
IOException {
+       public Bucket readFilter(Bucket bucket, BucketFactory bf, String 
charset, HashMap otherParams,
+               FilterCallback cb) throws DataFilterException, IOException {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                logDEBUG = Logger.shouldLog(Logger.DEBUG, this);
                if(logMINOR) Logger.minor(this, "readFilter(): 
charset="+charset);
@@ -76,7 +77,8 @@
                return temp;
        }

-       public Bucket writeFilter(Bucket bucket, BucketFactory bf, String 
charset, HashMap otherParams, FilterCallback cb) throws DataFilterException, 
IOException {
+       public Bucket writeFilter(Bucket bucket, BucketFactory bf, String 
charset, HashMap otherParams,
+               FilterCallback cb) throws DataFilterException, IOException {
                throw new UnsupportedOperationException();
        }

@@ -150,7 +152,7 @@
                         */
                        StringBuilder b = new StringBuilder(100);
                        StringBuilder balt = new StringBuilder(4000);
-                       Vector splitTag = new Vector();
+                       Vector<String> splitTag = new Vector<String>();
                        String currentTag = null;
                        char pprevC = 0;
                        char prevC = 0;
@@ -218,7 +220,7 @@
                                                                
splitTag.add(b.toString());
                                                                b.setLength(0);
                                                                
processTag(splitTag, w, this);
-                                                               currentTag = 
(String)splitTag.get(0);
+                                                               currentTag = 
splitTag.get(0);
                                                                
splitTag.clear();
                                                                
balt.setLength(0);
                                                                mode = INTEXT;
@@ -314,7 +316,7 @@
                                                                if (!killTag)
                                                                        
processTag(splitTag, w, this);
                                                                killTag = false;
-                                                               currentTag = 
(String)splitTag.get(0);
+                                                               currentTag = 
splitTag.get(0);
                                                                
splitTag.clear();
                                                                b.setLength(0);
                                                                
balt.setLength(0);
@@ -402,7 +404,7 @@
                w.write(sout);
        }

-       void processTag(Vector splitTag, Writer w, HTMLParseContext pc)
+       void processTag(Vector<String> splitTag, Writer w, HTMLParseContext pc)
                throws IOException, DataFilterException {
                // First, check that it is a recognized tag
                if(logDEBUG) {
@@ -498,7 +500,7 @@
                        this.endSlash = t.endSlash;
                }

-               public ParsedTag(Vector v) {
+               public ParsedTag(Vector<String> v) {
                        int len = v.size();
                        if (len == 0) {
                                element = null;
@@ -506,7 +508,7 @@
                                startSlash = endSlash = false;
                                return;
                        }
-                       String s = (String) v.elementAt(len - 1);
+                       String s = v.elementAt(len - 1);
                        if (((len - 1 != 0) || (s.length() > 1)) && 
s.endsWith("/")) {
                                s = s.substring(0, s.length() - 1);
                                v.setElementAt(s, len - 1);
@@ -515,17 +517,17 @@
                                endSlash = true;
                                // Don't need to set it back because everything 
is an I-value
                        } else endSlash = false;
-                       s = (String) v.elementAt(0);
+                       s = v.elementAt(0);
                        if ((s.length() > 1) && s.startsWith("/")) {
                                s = s.substring(1);
                                v.setElementAt(s, 0);
                                startSlash = true;
                        } else startSlash = false;
-                       element = (String) v.elementAt(0);
+                       element = v.elementAt(0);
                        if (len > 1) {
                                unparsedAttrs = new String[len - 1];
                                for (int x = 1; x < len; x++)
-                                       unparsedAttrs[x - 1] = (String) 
v.elementAt(x);
+                                       unparsedAttrs[x - 1] = v.elementAt(x);
                        } else
                                unparsedAttrs = new String[0];
                        if(logDEBUG) Logger.debug(this, "Element = "+element);
@@ -533,7 +535,7 @@

                public ParsedTag sanitize(HTMLParseContext pc) throws 
DataFilterException {
                        TagVerifier tv =
-                               (TagVerifier) 
allowedTagsVerifiers.get(element.toLowerCase());
+                               allowedTagsVerifiers.get(element.toLowerCase());
                        if(logDEBUG) Logger.debug(this, "Got verifier: "+tv+" 
for "+element);
                        if (tv == null) {
                                if (deleteWierdStuff) {
@@ -575,7 +577,7 @@
                }
        }

-       static final Hashtable allowedTagsVerifiers = new Hashtable();
+       static final Hashtable<String, TagVerifier> allowedTagsVerifiers = new 
Hashtable<String, TagVerifier>();
        static final String[] emptyStringArray = new String[0];

        static {
@@ -1130,9 +1132,9 @@

        static class TagVerifier {
                final String tag;
-               final HashSet allowedAttrs;
-               final HashSet uriAttrs;
-               final HashSet inlineURIAttrs;
+               final HashSet<String> allowedAttrs;
+               final HashSet<String> uriAttrs;
+               final HashSet<String> inlineURIAttrs;

                TagVerifier(String tag, String[] allowedAttrs) {
                        this(tag, allowedAttrs, null, null);
@@ -1140,17 +1142,17 @@

                TagVerifier(String tag, String[] allowedAttrs, String[] 
uriAttrs, String[] inlineURIAttrs) {
                        this.tag = tag;
-                       this.allowedAttrs = new HashSet();
+                       this.allowedAttrs = new HashSet<String>();
                        if (allowedAttrs != null) {
                                for (int x = 0; x < allowedAttrs.length; x++)
                                        this.allowedAttrs.add(allowedAttrs[x]);
                        }
-                       this.uriAttrs = new HashSet();
+                       this.uriAttrs = new HashSet<String>();
                        if (uriAttrs != null) {
                                for (int x = 0; x < uriAttrs.length; x++)
                                        this.uriAttrs.add(uriAttrs[x]);
                        }
-                       this.inlineURIAttrs = new HashSet();
+                       this.inlineURIAttrs = new HashSet<String>();
                        if (inlineURIAttrs != null) {
                                for (int x = 0; x < inlineURIAttrs.length; x++)
                                        
this.inlineURIAttrs.add(inlineURIAttrs[x]);
@@ -1158,7 +1160,7 @@
                }

                ParsedTag sanitize(ParsedTag t, HTMLParseContext pc) throws 
DataFilterException {
-                       Hashtable h = new Hashtable();
+                       Hashtable<String, Object> h = new Hashtable<String, 
Object>();
                        boolean equals = false;
                        String prevX = "";
                        if (t.unparsedAttrs != null)
@@ -1208,8 +1210,8 @@
                                return new ParsedTag(t, null);
                        String[] outAttrs = new String[h.size()];
                        int i = 0;
-                       for (Enumeration e = h.keys(); e.hasMoreElements();) {
-                               String x = (String) e.nextElement();
+                       for (Enumeration<String> e = h.keys(); 
e.hasMoreElements();) {
+                               String x = e.nextElement();
                                Object o = h.get(x);
                                String y;
                                if (o instanceof String)
@@ -1224,13 +1226,12 @@
                        return new ParsedTag(t, outAttrs);
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = new Hashtable();
-                       for (Enumeration e = h.keys(); e.hasMoreElements();) {
-                               String x = (String) e.nextElement();
+                       Hashtable<String, Object> hn = new Hashtable<String, 
Object>();
+                       for (Enumeration<String> e = h.keys(); 
e.hasMoreElements();) {
+                               String x = e.nextElement();
                                Object o = h.get(x);
                                // Straight attribs
                                if (allowedAttrs.contains(x)) {
@@ -1320,11 +1321,10 @@
                abstract void processStyle(HTMLParseContext pc);

                @Override
-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        if (p.startSlash) {
                                return finish(h, hn, pc);
                        } else {
@@ -1332,9 +1332,7 @@
                        }
                }

-               Hashtable finish(
-                       Hashtable h,
-                       Hashtable hn,
+               Hashtable<String, Object> finish(Hashtable<String, Object> h, 
Hashtable<String, Object> hn,
                        HTMLParseContext pc) throws DataFilterException {
                        if(logDEBUG) Logger.debug(this, "Finishing 
script/style");
                        // Finishing
@@ -1360,7 +1358,8 @@
                        return hn;
                }

-               Hashtable start(Hashtable h, Hashtable hn, HTMLParseContext pc) 
throws DataFilterException {
+               Hashtable<String, Object> start(Hashtable<String, Object> h, 
Hashtable<String, Object> hn, HTMLParseContext pc)
+                       throws DataFilterException {
                        if(logDEBUG) Logger.debug(this, "Starting 
script/style");
                        pc.styleScriptRecurseCount++;
                        if (pc.styleScriptRecurseCount > 1) {
@@ -1430,8 +1429,7 @@
                         */
                }

-               Hashtable sanitizeHash(
-                       Hashtable hn,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> hn,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
                        // Call parent so we swallow the scripting
@@ -1462,11 +1460,10 @@
                        super(tag, allowedAttrs, uriAttrs, inlineURIAttrs);
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        // %i18n dealt with by TagVerifier
                        // %coreattrs
                        String id = getHashString(h, "id");
@@ -1498,7 +1495,7 @@
        }

        static class CoreTagVerifier extends BaseCoreTagVerifier {
-               final HashSet eventAttrs;
+               final HashSet<String> eventAttrs;
                static final String[] stdEvents =
                        new String[] {
                                "onclick",
@@ -1543,7 +1540,7 @@
                        String[] eventAttrs,
                        boolean addStdEvents) {
                        super(tag, allowedAttrs, uriAttrs, inlineURIAttrs);
-                       this.eventAttrs = new HashSet();
+                       this.eventAttrs = new HashSet<String>();
                        if (eventAttrs != null) {
                                for (int x = 0; x < eventAttrs.length; x++)
                                        this.eventAttrs.add(eventAttrs[x]);
@@ -1554,14 +1551,13 @@
                        }
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        // events (default and added)
-                       for (Iterator e = eventAttrs.iterator(); e.hasNext();) {
-                               String name = (String) e.next();
+                       for (Iterator<String> e = eventAttrs.iterator(); 
e.hasNext();) {
+                               String name = e.next();
                                String arg = getHashString(h, name);
                                if (arg != null) {
                                        arg = sanitizeScripting(arg);
@@ -1584,11 +1580,10 @@
                        super(tag, allowedAttrs, uriAttrs, inlineURIAttrs, 
eventAttrs);
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        String hreflang = getHashString(h, "hreflang");
                        String charset = null;
                        String type = getHashString(h, "type");
@@ -1665,11 +1660,10 @@
                        super(tag, allowedAttrs, uriAttrs, null, eventAttrs);
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        if(p.startSlash) {
                                // Allow, but only with standard elements
                                return hn;
@@ -1694,7 +1688,7 @@
        }

        static class InputTagVerifier extends CoreTagVerifier{
-               final HashSet allowedTypes;
+               final HashSet<String> allowedTypes;
                String[] types = new String[]{
                        "text",
                        "password",
@@ -1715,18 +1709,17 @@
                        String[] inlineURIAttrs,
                        String[] eventAttrs) {
                        super(tag, allowedAttrs, uriAttrs, inlineURIAttrs, 
eventAttrs);
-                       this.allowedTypes = new HashSet();
+                       this.allowedTypes = new HashSet<String>();
                        if (types != null) {
                                for (int x = 0; x < types.length; x++)
                                        this.allowedTypes.add(types[x]);
                        }
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);

                        // We drop the whole <input> if type isn't allowed
                        if(!allowedTypes.contains(hn.get("type"))){
@@ -1742,11 +1735,10 @@
                        super("meta", new String[] { "id" });
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        /*
                         * Several possibilities: a) meta http-equiv=X 
content=Y b) meta
                         * name=X content=Y
@@ -1826,7 +1818,7 @@
                        super(tag, null);
                }

-               static final Hashtable DTDs = new Hashtable();
+               static final Hashtable<String, Object> DTDs = new 
Hashtable<String, Object>();

                static {
                        DTDs.put(
@@ -1897,11 +1889,10 @@
                        super("html", new String[] { "id", "version" });
                }

-               Hashtable sanitizeHash(
-                       Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                        ParsedTag p,
                        HTMLParseContext pc) throws DataFilterException {
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        String xmlns = getHashString(h, "xmlns");
                        if ((xmlns != null) && 
xmlns.equals("http://www.w3.org/1999/xhtml";))
                                hn.put("xmlns", xmlns);
@@ -1915,11 +1906,10 @@
                        super(string, strings, strings2, null);
                }

-               Hashtable sanitizeHash(
-                               Hashtable h,
+               Hashtable<String, Object> sanitizeHash(Hashtable<String, 
Object> h,
                                ParsedTag p,
                                HTMLParseContext pc) throws DataFilterException 
{
-                       Hashtable hn = super.sanitizeHash(h, p, pc);
+                       Hashtable<String, Object> hn = super.sanitizeHash(h, p, 
pc);
                        // Get the already-sanitized version.
                        String baseHref = getHashString(hn, "href");
                        if(baseHref != null) {
@@ -2075,7 +2065,7 @@
                return cb.processURI(suri, overrideType, false, inline);
        }

-       static String getHashString(Hashtable h, String key) {
+       static String getHashString(Hashtable<String, Object> h, String key) {
                Object o = h.get(key);
                if (o == null)
                        return null;

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-09-07 14:09:06 UTC 
(rev 22527)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-09-07 14:27:36 UTC 
(rev 22528)
@@ -49,7 +49,6 @@
 import freenet.io.comm.Peer;
 import freenet.io.comm.PeerContext;
 import freenet.io.comm.PeerParseException;
-import freenet.io.comm.PortForwardSensitiveSocketHandler;
 import freenet.io.comm.ReferenceSignatureVerificationException;
 import freenet.io.comm.SocketHandler;
 import freenet.io.xfer.PacketThrottle;
@@ -65,7 +64,6 @@
 import freenet.support.IllegalBase64Exception;
 import freenet.support.LRUHashtable;
 import freenet.support.Logger;
-import freenet.support.ShortBuffer;
 import freenet.support.SimpleFieldSet;
 import freenet.support.TimeUtil;
 import freenet.support.WouldBlockException;
@@ -74,8 +72,6 @@
 import freenet.support.math.TimeDecayingRunningAverage;
 import freenet.support.transport.ip.HostnameSyntaxException;
 import freenet.support.transport.ip.IPUtil;
-import java.util.SortedSet;
-import java.util.TreeSet;

 /**
  * @author amphibian


Reply via email to