Parser(3pm)
π Parser(3pm) π
okay bestie, sit down, grab your matcha π΅ β this is HTML::StripScripts::Parser, an XSS filter that rides on top of HTML::Parser, and it's lowkey iconic. She's part of the Perl user-contributed docs, she's giving security-but-make-it-cute, and she's about to eat. π
β¨ NAME β¨
HTML::StripScripts::Parser β XSS filter using HTML::Parser π‘οΈπ¦
β¨ SYNOPSIS β¨
like, here's the whole vibe in one go:
use HTML::StripScripts::Parser();
my $hss = HTML::StripScripts::Parser->new(
{
Context => 'Document', ## HTML::StripScripts configuration
Rules => { ... },
},
strict_comment => 1, ## HTML::Parser options
strict_names => 1,
);
$hss->parse_file("foo.html");
print $hss->filtered_document;
OR
print $hss->filter_html($html);
see how the first hashref is all HTML::StripScripts business and the stuff after it is pure HTML::Parser energy? that's the whole concept. slay. π
β¨ DESCRIPTION β¨
So this class is the easy interface to HTML::StripScripts β it uses HTML::Parser to actually chew through the HTML for you. π
If you wanna know how to customise the way the raw HTML gets parsed into tags, go read HTML::Parser. And if you wanna know how to customise the way those tags get filtered, that's all HTML::StripScripts. iykyk. π
β¨ CONSTRUCTORS β¨
new ( {CONFIG}, [PARSER_OPTIONS] )
Makes you a brand new HTML::StripScripts::Parser object. new object, who dis. β¨
- The
CONFIGparameter has the exact same semantics as theCONFIGparameter to theHTML::StripScriptsconstructor. same rules, same energy. - Any
PARSER_OPTIONSyou hand over get passed straight on to the HTML::Parser init method, so you can influence how the input gets parsed. π
β οΈ okay important, no cap: you cannot usePARSER_OPTIONSto set theHTML::Parserevent handlers (peep "Events" in HTML::Parser) β becauseHTML::StripScripts::Parseris already using all of those event hooks itself. she's booked and busy. π BUT. you can useRules(see "Rules" in HTML::StripScripts) to customise the handling of all tags and attributes. so you're not stuck, bestie. π
β¨ METHODS β¨
For input methods, go look at HTML::Parser. For output methods, go look at HTML::StripScripts. teamwork makes the dream work π«Ά
filter_html()
filter_html() is the lil convenience queen π β she filters HTML that's already loaded into a scalar variable. Basically she's just three calls in a trench coat: HTML::Parser::parse(), HTML::Parser::eof(), and HTML::StripScripts::filtered_document(). β¨
$filtered_html = $hss->filter_html($html);
one line, zero stress, she ate. π₯
β¨ SUBCLASSING β¨
The HTML::StripScripts::Parser class is subclassable β yes, you can make her your own. π
- Filter objects are just plain hashes. no fancy blessed struct situation, just vibes. π
- The
hss_init()method takes the same arguments asnew(), and it calls the initialization methods of bothHTML::StripScriptsandHTML::Parser. double the init, double the fun. π
Also go read "SUBCLASSING" in HTML::StripScripts and "SUBCLASSING" in HTML::Parser for the full lore. π
β¨ SEE ALSO β¨
HTML::StripScriptsHTML::ParserHTML::StripScripts::LibXML
the whole friend group π
β¨ BUGS β¨
None reported. β¨ literally flawless behaviour (so far π).
If you do find bugs or have feature requests, please report them to bug-html-stripscripts-parser@rt.cpan.org, or slide through the web interface at <http://rt.cpan.org>. don't be shy, they wanna hear it. π«Ά
β¨ AUTHOR β¨
- Original author: Nick Cleaton
<nick@cleaton.net> - New code added and module maintained by: Clinton Gormley
<clint@traveljury.com>
shoutout to the OGs π«‘π
β¨ COPYRIGHT β¨
- Copyright (C) 2003 Nick Cleaton. All Rights Reserved.
- Copyright (C) 2007 Clinton Gormley. All Rights Reserved.
β¨ LICENSE β¨
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt. π
and that's the whole page, bestie π go forth and sanitise responsibly β¨π¦
perl v5.32.0 Β· 2021-01-03 Β· Parser(3pm) β mwah, catch you in the next manpage, love u, bye ππ
π¦ where this page comes from
- debian bookworm: libhtml-stripscripts-parser-perl 1.03-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libhtml-stripscripts-parser-perl 1.03-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libhtml-stripscripts-parser-perl 1.03-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-stripscripts-parser-perl 1.03-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-stripscripts-parser-perl 1.03-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libhtml-stripscripts-parser-perl 1.03-2.1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms