Add API to unescape HTML entities
This commit is contained in:
parent
b97acb1e21
commit
ec21297448
File diff suppressed because one or more lines are too long
@ -266,6 +266,27 @@ $tmp =~ s/=/=/g;
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
=head2 html_unescape(string)
|
||||
|
||||
Converts HTML entities to the corresponding character
|
||||
|
||||
=cut
|
||||
sub html_unescape
|
||||
{
|
||||
my ($str) = @_;
|
||||
if (!defined $str) {
|
||||
return ''; # empty string
|
||||
};
|
||||
$str =~ s/&/&/g;
|
||||
$str =~ s/</</g;
|
||||
$str =~ s/>/>/g;
|
||||
$str =~ s/"/"/g;
|
||||
$str =~ s/'/'/g;
|
||||
$str =~ s/=/=/g;
|
||||
$str =~ s/ / /g;
|
||||
return $str;
|
||||
}
|
||||
|
||||
=head2 html_strip(string, replacement)
|
||||
|
||||
Removes any HTML from a string, replacing with nothing or given chars
|
||||
|
Loading…
x
Reference in New Issue
Block a user