From 377bcacff8651ce107bd0cc6bea25ba520f73e4c Mon Sep 17 00:00:00 2001 From: MUY Date: Thu, 1 Jun 2017 06:43:59 +0200 Subject: [PATCH] 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. --- web-lib-funcs.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/web-lib-funcs.pl b/web-lib-funcs.pl index 91e7fbe9c..5a1d05ac3 100755 --- a/web-lib-funcs.pl +++ b/web-lib-funcs.pl @@ -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; }