|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.darwinsys.html.SimpleTagValidator
public class SimpleTagValidator
Check a String to ensure that it contains either no HTML tags, or only the HTML tags listed in OKTAGS (or the corresponding end-tags). It is not intended as a full-function HTML validator! Nor is any claim advanced that this is a complete solution to preventing Cross-Site Scripting. It is just, well, a SIMPLE Tag Validator.
Constructor Summary | |
---|---|
SimpleTagValidator()
Construct a Validator using the default OK list |
|
SimpleTagValidator(java.lang.String[] okTagList)
Construct a Validator using a non-default OK list |
Method Summary | |
---|---|
java.lang.String |
getFailedTag()
Return the last tag that failed. |
java.lang.String |
getTagsAsString(boolean useCommas)
Return the list of valid tags as a single string. |
boolean |
validate(java.lang.String s)
Validate a String that may contain HTML to ensure it contains only the tags listed in the OK list. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SimpleTagValidator()
public SimpleTagValidator(java.lang.String[] okTagList)
Method Detail |
---|
public boolean validate(java.lang.String s)
s
- The HTML String to validate.
public java.lang.String getFailedTag()
System.out.printf("Invalid tag %s\n", val.getFailedTag());
public java.lang.String getTagsAsString(boolean useCommas)
System.out.printf("Valid tags are %01s\n", val.tagsAsString());
useCommas
- True to include commas ("a, b, c"); false just space ("a b c").
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |