HTML::...scapes(3pm)
π HTML::Mason::Escapes π
okay bestie, so this is the manual page for HTML::Mason::Escapes, and it lives in section 3pm of the User Contributed Perl Documentation, iykyk π pull up a chair, we're talking about escaping text for Mason.
β¨ NAME β¨
HTML::Mason::Escapes β literally just functions that escape text for Mason, no cap π¦
πΈ DESCRIPTION πΈ
so this module is where Mason keeps the functions that make its substitution escaping feature work β¨. and the cute part? you can also call these functions directly yourself β they're not gatekept, bestie π
π§ html_entities_escape
this one takes a scalar reference and HTML-escapes it using the HTML::Entities module π
by default, this module assumes the string it's escaping is in ISO-8859-1 (that's pre Perl 5.8.0) or UTF-8 (Perl 5.8.0 onwards) π
so if your data is NOT in one of those encodings, you're gonna wanna override this escape to do the right thing for your encoding. do not just vibe past this, fr fr π
see the section on User-defined Escapes in the Developer's Manual for more deets on how to actually do that π«Ά
π¦ url_escape
this one takes a scalar reference and replaces any text it contains matching [^a-zA-Z0-9_.-] with the URL-escaped equivalent π«
and what's that equivalent? a percent sign (%) followed by the hexadecimal number of that character πΈ iconic behaviour honestly
π basic_html_escape
this function takes a scalar reference and HTML-escapes it, escaping the following characters: '&', '>', '<', and '"' β
it's provided for those who wish to use it to replace (or supplement) the existing 'h' escape flag, via the Interpreter's set_escape() method π
β οΈ okay this next part is IMPORTANT, bestie, listen up. this function is provided in order to allow people to return the HTML escaping behavior in 1.0x. HOWEVER, this behavior presents a potential security risk of allowing cross-site scripting attacks πππ
HTML escaping should always be done based on the character set a page is in. merely escaping the four characters mentioned above is not sufficient π€
the quick summary of why: for some character sets, characters other than '<' may be interpreted as a "less than" sign, meaning that just filtering '<' and '>' will not stop all cross-site scripting attacks π
see http://www.megasecurity.org/Info/cross-site_scripting.txt for more details π₯
and that's the whole page, bestie!! π this was written for perl v5.38.2, dated 2024-03-05, and it's the HTML::...scapes(3pm) manpage β go forth and escape responsibly, mwah πβ¨π¦
π¦ where this page comes from
- debian trixie: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libhtml-mason-perl 1:1.60-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libhtml-mason-perl 1:1.60-2 Β· 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