Author: sback
Date: 2007-08-19 15:36:43 +0000 (Sun, 19 Aug 2007)
New Revision: 14798

Modified:
   trunk/freenet/src/freenet/support/HTMLNode.java
Log:
assertion on node name, thanks to nextgens

Modified: trunk/freenet/src/freenet/support/HTMLNode.java
===================================================================
--- trunk/freenet/src/freenet/support/HTMLNode.java     2007-08-19 14:52:05 UTC 
(rev 14797)
+++ trunk/freenet/src/freenet/support/HTMLNode.java     2007-08-19 15:36:43 UTC 
(rev 14798)
@@ -8,8 +8,12 @@
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;

 public class HTMLNode {
+       
+       private static final Pattern namePattern = 
Pattern.compile("^[a-zA-Z][a-zA-Z_0-9]+$");

        protected final String name;

@@ -36,6 +40,11 @@
        }

        public HTMLNode(String name, String[] attributeNames, String[] 
attributeValues, String content) {
+               
+               Matcher nameMatcher = namePattern.matcher(name);
+               
+               assert nameMatcher.matches();
+               
                this.name = name.toLowerCase(Locale.ENGLISH);
                if ((attributeNames != null) && (attributeValues != null)) {
                        if (attributeNames.length != attributeValues.length) {


Reply via email to