File: PurePerl.pm

package info (click to toggle)
libhtml-escape-perl 1.11-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 312 kB
  • sloc: perl: 59; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 592 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package HTML::Escape::PurePerl;
use strict;
use warnings;
use utf8;

die qq{Don't use HTML::Escape::PurePerl directly, use HTML::Escape instead.\n} # ' for poor editors
        if caller() ne 'HTML::Escape';

package # do not index, pause.
    HTML::Escape;

our %_escape_table = ( '&' => '&amp;', '>' => '&gt;', '<' => '&lt;', q{"} => '&quot;', q{'} => '&#39;', q{`} => '&#96;', '{' => '&#123;', '}' => '&#125;' );
sub escape_html {
    my $str = shift;
    return ''
        unless defined $str;
    $str =~ s/([&><"'`{}])/$_escape_table{$1}/ge; #' for poor editors
    return $str;
}

1;