1 package Newslash::Model::Util;
2 use Newslash::Model::Base -base;
10 =head2 clean_html(\%allowed, $html)
26 allowed tag and attribute
39 my ($self, $allowed, $html) = @_;
40 my $escaped = $self->escape_html($allowed, $html);
41 $escaped = EscapeHTML::blank_line_to_paragraph($escaped);
43 my $tidy = HTML::Tidy->new( {
46 'show-body-only' => 1,
48 my $tidied = $tidy->clean($escaped);
53 =head2 escape_html(\%allowed, $html)
69 allowed tag and attribute
82 my ($self, $allowed, $html) = @_;
83 return EscapeHTML::escape($allowed, $html);
87 =head2 escape_plaintext($text)
111 sub escape_plaintext {
112 my ($self, $text) = @_;
114 my $t = $text->replace(qr/&(?!|lt;|gt;)/, '&');
115 $t = $t->replace(qr/</, '<');
116 $t = $t->replace(qr/>/, '>');