Package org.owasp.html
Class TagBalancingHtmlStreamEventReceiver
- java.lang.Object
-
- org.owasp.html.TagBalancingHtmlStreamEventReceiver
-
- All Implemented Interfaces:
HtmlStreamEventReceiver
public class TagBalancingHtmlStreamEventReceiver extends Object implements HtmlStreamEventReceiver
Wraps an HTML stream event receiver to fill in missing close tags. If the balancer is given the HTML<p>1<p>2
, the wrapped receiver will see events equivalent to<p>1</p><p>2</p>
.- Author:
- Mike Samuel ([email protected])
-
-
Constructor Summary
Constructors Constructor Description TagBalancingHtmlStreamEventReceiver(HtmlStreamEventReceiver underlying)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closeDocument()
Called first to indicate that no more events will be received.void
closeTag(String elementName)
Called to specify an end tag like</elementName>
.static boolean
isInterElementWhitespace(String text)
True if text is the value of an inter-element whitespace text node as defined by HTML5.void
openDocument()
Called first to indicate that events follow.void
openTag(String elementName, List<String> attrs)
Called to specify a tag with the given name and attributes.void
setNestingLimit(int limit)
Set the maximum element nesting depth.void
text(String text)
Called to specify a text node.
-
-
-
Constructor Detail
-
TagBalancingHtmlStreamEventReceiver
public TagBalancingHtmlStreamEventReceiver(HtmlStreamEventReceiver underlying)
- Parameters:
underlying
- An event receiver that should receive a stream of balanced events that is as close as possible to the stream of events received by this.
-
-
Method Detail
-
setNestingLimit
public void setNestingLimit(int limit)
Set the maximum element nesting depth.
-
openDocument
public void openDocument()
Description copied from interface:HtmlStreamEventReceiver
Called first to indicate that events follow.- Specified by:
openDocument
in interfaceHtmlStreamEventReceiver
-
closeDocument
public void closeDocument()
Description copied from interface:HtmlStreamEventReceiver
Called first to indicate that no more events will be received.- Specified by:
closeDocument
in interfaceHtmlStreamEventReceiver
-
openTag
public void openTag(String elementName, List<String> attrs)
Description copied from interface:HtmlStreamEventReceiver
Called to specify a tag with the given name and attributes.- Specified by:
openTag
in interfaceHtmlStreamEventReceiver
attrs
- alternating attribute names and values.
-
closeTag
public void closeTag(String elementName)
Description copied from interface:HtmlStreamEventReceiver
Called to specify an end tag like</elementName>
.- Specified by:
closeTag
in interfaceHtmlStreamEventReceiver
-
isInterElementWhitespace
public static boolean isInterElementWhitespace(String text)
True if text is the value of an inter-element whitespace text node as defined by HTML5.This is the kind of text that is often inserted by HTML authors to nicely indent their HTML documents and which (modulo unconventional use of
white-space:pre
) are not apparent to the end-user.
-
text
public void text(String text)
Description copied from interface:HtmlStreamEventReceiver
Called to specify a text node.- Specified by:
text
in interfaceHtmlStreamEventReceiver
-
-