Author: sback
Date: 2007-08-20 15:53:25 +0000 (Mon, 20 Aug 2007)
New Revision: 14804
Modified:
trunk/freenet/src/freenet/support/HTMLNode.java
Log:
BUGFIXING: Included a check when adding a new attribute to avoid the insertion
of null -name or value- attribute. Otherwise there are problems when calling
generate()
Modified: trunk/freenet/src/freenet/support/HTMLNode.java
===================================================================
--- trunk/freenet/src/freenet/support/HTMLNode.java 2007-08-20 14:10:51 UTC
(rev 14803)
+++ trunk/freenet/src/freenet/support/HTMLNode.java 2007-08-20 15:53:25 UTC
(rev 14804)
@@ -51,7 +51,7 @@
throw new IllegalArgumentException("attribute
names and values differ");
}
for (int attributeIndex = 0, attributeCount =
attributeNames.length; attributeIndex < attributeCount; attributeIndex++) {
- attributes.put(attributeNames[attributeIndex],
attributeValues[attributeIndex]);
+ addAttribute(attributeNames[attributeIndex],
attributeValues[attributeIndex]);
}
}
if (content != null && !name.equals("#") && !name.equals("%")) {
@@ -69,6 +69,10 @@
}
public void addAttribute(String attributeName, String attributeValue) {
+ if (attributeName == null)
+ throw new IllegalArgumentException("Cannot add an
attribute with a null name");
+ if (attributeValue == null)
+ throw new IllegalArgumentException("Cannot add an
attribute with a null value");
attributes.put(attributeName, attributeValue);
}