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:
parent
1379d2cc35
commit
377bcacff8
@ -195,13 +195,16 @@ Useful for outputing HTML tag values.
|
|||||||
sub quote_escape
|
sub quote_escape
|
||||||
{
|
{
|
||||||
my ($tmp, $only) = @_;
|
my ($tmp, $only) = @_;
|
||||||
|
if (!defined $tmp) {
|
||||||
|
return ''; # empty string
|
||||||
|
};
|
||||||
if ($tmp !~ /\&[a-zA-Z]+;/ && $tmp !~ /\&#/) {
|
if ($tmp !~ /\&[a-zA-Z]+;/ && $tmp !~ /\&#/) {
|
||||||
# convert &, unless it is part of &#nnn; or &foo;
|
# convert &, unless it is part of &#nnn; or &foo;
|
||||||
$tmp =~ s/&([^#])/&$1/g;
|
$tmp =~ s/&([^#])/&$1/g;
|
||||||
}
|
}
|
||||||
$tmp =~ s/&$/&/g;
|
$tmp =~ s/&$/&/g;
|
||||||
$tmp =~ s/\"/"/g if ($only eq '' || $only eq '"');
|
$tmp =~ s/\"/"/g if (!$only || $only eq '"');
|
||||||
$tmp =~ s/\'/'/g if ($only eq '' || $only eq "'");
|
$tmp =~ s/\'/'/g if (!$only || $only eq "'");
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user