1Parser(3) User Contributed Perl Documentation Parser(3)
2
3
4
6 HTML::StripScripts::Parser - XSS filter using HTML::Parser
7
9 use HTML::StripScripts::Parser();
10
11 my $hss = HTML::StripScripts::Parser->new(
12
13 {
14 Context => 'Document', ## HTML::StripScripts configuration
15 Rules => { ... },
16 },
17
18 strict_comment => 1, ## HTML::Parser options
19 strict_names => 1,
20
21 );
22
23 $hss->parse_file("foo.html");
24
25 print $hss->filtered_document;
26
27 OR
28
29 print $hss->filter_html($html);
30
32 This class provides an easy interface to "HTML::StripScripts", using
33 "HTML::Parser" to parse the HTML.
34
35 See HTML::Parser for details of how to customise how the raw HTML is
36 parsed into tags, and HTML::StripScripts for details of how to
37 customise the way those tags are filtered.
38
40 new ( {CONFIG}, [PARSER_OPTIONS] )
41 Creates a new "HTML::StripScripts::Parser" object.
42
43 The CONFIG parameter has the same semantics as the CONFIG parameter
44 to the "HTML::StripScripts" constructor.
45
46 Any PARSER_OPTIONS supplied will be passed on to the HTML::Parser
47 init method, allowing you to influence the way the input is parsed.
48
49 You cannot use PARSER_OPTIONS to set the "HTML::Parser" event
50 handlers (see "Events" in HTML::Parser) since
51 "HTML::StripScripts::Parser" uses all of the event hooks itself.
52 However, you can use "Rules" (see "Rules" in HTML::StripScripts) to
53 customise the handling of all tags and attributes.
54
56 See HTML::Parser for input methods, HTML::StripScripts for output
57 methods.
58
59 "filter_html()"
60 "filter_html()" is a convenience method for filtering HTML already
61 loaded into a scalar variable. It combines calls to
62 "HTML::Parser::parse()", "HTML::Parser::eof()" and
63 "HTML::StripScripts::filtered_document()".
64
65 $filtered_html = $hss->filter_html($html);
66
68 The "HTML::StripScripts::Parser" class is subclassable. Filter objects
69 are plain hashes. The hss_init() method takes the same arguments as
70 new(), and calls the initialization methods of both
71 "HTML::StripScripts" and "HTML::Parser".
72
73 See "SUBCLASSING" in HTML::StripScripts and "SUBCLASSING" in
74 HTML::Parser.
75
77 HTML::StripScripts, HTML::Parser, HTML::StripScripts::LibXML
78
80 None reported.
81
82 Please report any bugs or feature requests to
83 bug-html-stripscripts-parser@rt.cpan.org, or through the web interface
84 at <http://rt.cpan.org>.
85
87 Original author Nick Cleaton <nick@cleaton.net>
88
89 New code added and module maintained by Clinton Gormley
90 <clint@traveljury.com>
91
93 Copyright (C) 2003 Nick Cleaton. All Rights Reserved.
94
95 Copyright (C) 2007 Clinton Gormley. All Rights Reserved.
96
98 This module is free software; you can redistribute it and/or modify it
99 under the same terms as Perl itself.
100
101
102
103perl v5.32.1 2021-01-27 Parser(3)