Explorar o código

Fixing several occurences of 'Use of uninitialized value in substitution (s///)' (SF #1354920)

xtaran %!s(int64=20) %!d(string=hai) anos
pai
achega
8fc2b39afe
Modificáronse 3 ficheiros con 7 adicións e 2 borrados
  1. 3 0
      docs/Changelog
  2. 3 1
      modules/Pisg/Common.pm
  3. 1 1
      modules/Pisg/HTMLGenerator.pm

+ 3 - 0
docs/Changelog

@@ -1,5 +1,8 @@
 pisg (0.69) - ??
    Axel:
+   * PISG Bug fixes:
+     + Fixing several occurences of "Use of uninitialized
+       value in substitution (s///)" (SF #1354920)
    * PUM Bug fixes:
      + Missing and unclear documentation in pum.conf
    * PUM Features:

+ 3 - 1
modules/Pisg/Common.pm

@@ -182,10 +182,12 @@ sub htmlentities
     my $str = shift;
     my $charset = shift;
 
+    return $str unless $str;
+
     $str =~ s/\&/\&/go;
     $str =~ s/\</\&lt;/go;
     $str =~ s/\>/\&gt;/go;
-    if ($charset =~ /iso-8859-1/i) { # this is for people without Text::Iconv
+    if ($charset and $charset =~ /iso-8859-1/i) { # this is for people without Text::Iconv
         $str =~ s/ü/&uuml;/go;
         $str =~ s/ö/&ouml;/go;
         $str =~ s/ä/&auml;/go;

+ 1 - 1
modules/Pisg/HTMLGenerator.pm

@@ -2031,7 +2031,7 @@ sub _mosturls
             my $urlcount = $self->{stats}->{urlcounts}{$sorturls[$i]};
             my $lastused = $self->{stats}->{urlnicks}{$sorturls[$i]};
             my $printurl = $sorturls[$i];
-            if (length($printurl) > 60) {
+            if ($printurl and length($printurl) > 60) {
                 $printurl = substr($printurl, 0, 60);
             }
             $printurl = htmlentities($printurl, $self->{cfg}->{charset});