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 loaded
61 into a scalar variable. It combines calls to HTML::Parser::parse(),
62 HTML::Parser::eof() and HTML::StripScripts::filtered_document().
63
64 $filtered_html = $hss->filter_html($html);
65
67 The "HTML::StripScripts::Parser" class is subclassable. Filter objects
68 are plain hashes. The hss_init() method takes the same arguments as
69 new(), and calls the initialization methods of both
70 "HTML::StripScripts" and "HTML::Parser".
71
72 See "SUBCLASSING" in HTML::StripScripts and "SUBCLASSING" in
73 HTML::Parser.
74
76 HTML::StripScripts, HTML::Parser, HTML::StripScripts::LibXML
77
79 None reported.
80
81 Please report any bugs or feature requests to
82 bug-html-stripscripts-parser@rt.cpan.org, or through the web interface
83 at <http://rt.cpan.org>.
84
86 Original author Nick Cleaton <nick@cleaton.net>
87
88 New code added and module maintained by Clinton Gormley
89 <clint@traveljury.com>
90
92 Copyright (C) 2003 Nick Cleaton. All Rights Reserved.
93
94 Copyright (C) 2007 Clinton Gormley. All Rights Reserved.
95
97 This module is free software; you can redistribute it and/or modify it
98 under the same terms as Perl itself.
99
100
101
102perl v5.36.0 2023-01-20 Parser(3)