HTML::StripScripts::Parser3pm
Xss filter using html::parser
Usage
use HTML::StripScripts::Parser();my $hss = HTML::StripScripts::Parser->new({Context => 'Document', ## HTML::StripScripts configurationRules => { ... },},strict_comment => 1, ## HTML::Parser optionsstrict_names => 1,);$hss->parse_file("foo.html");print $hss->filtered_document;ORprint $hss->filter_html($html);
Overview
This class provides an easy interface to "HTML::StripScripts", using "HTML::Parser" to parse the HTML.
See HTML::Parser for details of how to customise how the raw HTML is parsed into tags, and HTML::StripScripts for details of how to customise the way those tags are filtered.
Constructors
- new ( {CONFIG}, [PARSER_OPTIONS] )
-
Creates a new
"HTML::StripScripts::Parser"object.The CONFIG parameter has the same semantics as the CONFIG parameter to the
"HTML::StripScripts"constructor.Any PARSER_OPTIONS supplied will be passed on to the HTML::Parser init method, allowing you to influence the way the input is parsed.
You cannot use PARSER_OPTIONS to set the
"HTML::Parser"event handlers (see "Events" in HTML::Parser) since"HTML::StripScripts::Parser"uses all of the event hooks itself. However, you can use"Rules"(see "Rules" in HTML::StripScripts) to customise the handling of all tags and attributes.
Methods
See HTML::Parser for input methods, HTML::StripScripts for output methods.
"filter_html()"
"filter_html()" is a convenience method for filtering HTML already loaded into a scalar variable. It combines calls to "HTML::Parser::parse()", "HTML::Parser::eof()" and "HTML::StripScripts::filtered_document()".
$filtered_html = $hss->filter_html($html);
Subclassing
The "HTML::StripScripts::Parser" class is subclassable. Filter objects are plain hashes. The hss_init() method takes the same arguments as new(), and calls the initialization methods of both "HTML::StripScripts" and "HTML::Parser".
See "SUBCLASSING" in HTML::StripScripts and "SUBCLASSING" in HTML::Parser.
Releases
8 releases since Debian 6.0 (Squeeze); the text changed 2 times.