Wednesday, August 17, 2016

Webcollage bug/irritation repair

So, I am enjoying my little Linux build with that little AMD APU detailed in my last post...  Something is missing...  YES!  A good screensaver.

Oh...  Yes it has been a while since my last post, so what?  I've been boating and working on the house and generally enjoying the outdoors while the weather is agreeable.  So...  pfft...

Anyway, I installed the XScreenSaver package with several additional screensaver packages.  One looked intriguing...  webcollage by Jamie Zawinski.  Webcollage uses dictionary files (just lists of words) to seed simple searches on several internet search engines.  When the screen saver is activated, a random image (or part of an image) from a random webpage from the results of searching a random word is placed on a the screen like a collage, one image over the other.

Needless to say there is a lot of online bitching about this because quite simply, it can display porn and other NSFW images.  OK, so some people don't like it.  Personally, I find it intriguing.  But...  occasionally the following text would show up on the screen...  sometimes several times before a screen redraw covered the text:

Use of uninitialized value $vals in index at /usr/share/perl5/HTTP/Headers.pm line 264
Use of uninitialized value $vals in concatenation(.) or string at /usr/share/perl5/HTTP/Headers.pm line 267

After trying a few repairs to the webcollage Perl source, I just went into Headers.pm and fixed it there.  Here's the repair:

sub as_string
{
    my($self, $endl) = @_;
    $endl = "\n" unless defined $endl;

    my @result = ();
    for my $key (@{ $self->_sorted_field_names }) {
next if index($key, '_') == 0;
my $vals = $self->{$key};
if ( ref($vals) eq 'ARRAY' ) {
   for my $val (@$vals) {
my $field = $standard_case{$key} || $self->{'::std_case'}{$key} || $key;
$field =~ s/^://;
if ( index($val, "\n") >= 0 ) {
   $val = _process_newline($val, $endl);
}
push @result, $field . ': ' . $val;
   }
}
else {
          if ( defined $vals ) {
   my $field = $standard_case{$key} || $self->{'::std_case'}{$key} || $key;
   $field =~ s/^://;
   if ( index($vals, "\n") >= 0 ) {
$vals = _process_newline($vals, $endl);
   }
   push @result, $field . ': ' . $vals;
          }
}
    }

    join($endl, @result, '');
}

My changes are in red.  Not sure if the bug is in webcollage or if it is in Headers.pm but here ya go.  This is the fix.  Damn, I love open source!

**Disclaimer:  I am NOT a Perl programmer, I only know enough to successfully poke around Perl source and figure things out.
**Suggestion: Anyone running webcollage might want to consider two things: 1) it uses internet resources to perform searches and retrieve images; 2) some of the images shown on the screen could really get a person in trouble at most companies, not to mention what might happen should certain significant others see certain images.

No comments:

Post a Comment