Author: nextgens
Date: 2006-05-17 09:43:42 +0000 (Wed, 17 May 2006)
New Revision: 8731
Modified:
trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
Log:
Content-filter : we whitelist input types insteed of blacklisting them
Modified: trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
2006-05-16 22:57:45 UTC (rev 8730)
+++ trunk/freenet/src/freenet/clients/http/filter/HTMLFilter.java
2006-05-17 09:43:42 UTC (rev 8731)
@@ -1606,12 +1606,31 @@
}
static class InputTagVerifier extends CoreTagVerifier{
+ final HashSet allowedTypes;
+ String[] types = new String[]{
+ "text",
+ "password",
+ "checkbox",
+ "radio",
+ "submit",
+ "reset,",
+ // no ! file
+ "hidden",
+ "image",
+ "button"
+ };
+
InputTagVerifier(
String tag,
String[] allowedAttrs,
String[] uriAttrs,
String[] eventAttrs) {
super(tag, allowedAttrs, uriAttrs, eventAttrs);
+ this.allowedTypes = new HashSet();
+ if (types != null) {
+ for (int x = 0; x < types.length; x++)
+ this.allowedTypes.add(types[x]);
+ }
}
Hashtable sanitizeHash(
@@ -1619,9 +1638,11 @@
ParsedTag p,
HTMLParseContext pc) throws DataFilterException {
Hashtable hn = super.sanitizeHash(h, p, pc);
- // We dont want to allow type=file
- if(((String)hn.get("type")).equalsIgnoreCase("file"))
+
+ // We drop the whole <input> if type isn't allowed
+ if(!allowedTypes.contains(hn.get("type"))){
return null;
+ }
return hn;
}