|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.goodeast.webobjects.switchablestring.SSHTMLFilter
Implements the base functionality for a scheme to filter out HTML tags based on a test. Subclasses need to implement the method tagShouldBeEscaped() which takes a String containing the tag and returns true or false depending on whether or not the tag should be escaped by using & HTML entity or not.
Nested Class Summary | |
static class |
SSHTMLFilter.Factory
Factory class that implements a caching scheme to avoid the overhead of creating a new object each time a new filter is desired with the same allowed or disallowed list. |
Constructor Summary | |
protected |
SSHTMLFilter()
Used by SSHTMLFilter subclasses. |
Method Summary | |
java.lang.String |
filterForAllowedHTML(java.lang.String rawString)
This is a complex method that parses the raw string looking for tags. |
abstract boolean |
tagShouldBeEscaped(java.lang.String tag)
Method called to determine if a particular tag should be escaped or not. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected SSHTMLFilter()
Method Detail |
public java.lang.String filterForAllowedHTML(java.lang.String rawString)
append A3 to resultAfter all tokens have been processed, we need to deal with edge cases after the end of the loop.
shift A2 to A3
shift A1 to A2
load next token into A1
if inside a tagif A1 == ">"else if outside a tagchange state to outside a tagif A2 == "<" and A1 !="/"if A1.firstWord in disallowedList or A1.firstWord not in allowedListif A3 == "<" and A2 == "/"change A2 to "<"else if A1.firstWord is not BR or LIpush A1.firstWord onto Bchange state to inside a tagif A1.firstWord in disallowedList or A1.firstWord not in allowedListchange A3 to "<"else if B.top == A2.firstWordpop Bchange state to inside a tag
convert A1 to "<"if A2 == "<" and A1 == "/"
convert A2 to "<"if A2 == "<" and A1 == "!"
convert A2 to "<"flush A1, A2 A3 to result
append ">" to resultpop elements off of B and create close tags for them
rawString
- String containing possible undesired and/or malformed
HTML
public abstract boolean tagShouldBeEscaped(java.lang.String tag)
tag
- Tag to be checked
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |