Update web-lib-funcs.pl

quote_escape - usually used to concatenate to string, so the function should always return a string, even if first argument is undef.  The usage of the eq operator on an undef variable cause a warning, in addition '' is evaluated to 'false' in conditions.
This commit is contained in:
MUY 2017-06-01 06:43:59 +02:00 committed by GitHub
parent 1379d2cc35
commit 377bcacff8

View File

@ -195,13 +195,16 @@ Useful for outputing HTML tag values.
sub quote_escape
{
my ($tmp, $only) = @_;
if (!defined $tmp) {
return ''; # empty string
};
if ($tmp !~ /\&[a-zA-Z]+;/ && $tmp !~ /\&#/) {
# convert &, unless it is part of &#nnn; or &foo;
$tmp =~ s/&([^#])/&$1/g;
}
$tmp =~ s/&$/&/g;
$tmp =~ s/\"/"/g if ($only eq '' || $only eq '"');
$tmp =~ s/\'/'/g if ($only eq '' || $only eq "'");
$tmp =~ s/\"/"/g if (!$only || $only eq '"');
$tmp =~ s/\'/'/g if (!$only || $only eq "'");
return $tmp;
}