Skip Menu |

This queue is for tickets about the Win32-IEFavorites CPAN distribution.

Report information
The Basics
Id: 76744
Status: resolved
Priority: 0/
Queue: Win32-IEFavorites

People
Owner: Nobody in particular
Requestors: collectjunkemail [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: _load in Win32::IEFavorites::Item Fail when a .url file is corrupt or missing information
Date: Sat, 21 Apr 2012 22:49:16 +0800
To: <bug-Win32-IEFavorites [...] rt.cpan.org>
From: "Shiraz Qureshi" <collectjunkemail [...] hotmail.com>
Hi; I came across an issue where the .url in the Favorites was a recovered .url, which was missing information like url path, etc. It was a completely empty .url file except it was present and had a valid path and name. In this case, the Item.pm would cause an error when the calling perl script would invoke $my_item->url. This call invoked the _load in the process and the error would happen where there was nothing handling for the case if my $ini = undef. If I added the check to confirm $ini is defined prior to using it then the error from Perl disappeared. The Perl error was Can't call method ‘val’ on an undefined value... I have provided the following sample code to fix the issue. sub _load { my $self = shift; my $ini = Config::IniFiles->new( -file => $self->{path} ); foreach my $type (qw/URL Modified IconFile IconIndex/) { if (defined $ini){ $self->{lc($type)} = $ini->val('InternetShortcut',$type) || ''; } else { $self->{lc($type)} = ''; } } $self->{cached} = 1; } Thank you for writing this code in the first place. Regards Sam
Thank you for your report and patch. Applied and released 0.06 to the CPAN. On Sat Apr 21 23:49:36 2012, collectjunkemail@hotmail.com wrote: Show quoted text
> Hi; > > I came across an issue where the .url in the Favorites was a recovered > .url, which was missing information like url path, etc. It was a > completely empty .url file except it was present and had a valid > path and name. In this case, the Item.pm would cause an error when > the calling perl script would invoke $my_item->url. This call > invoked the _load in the process and the error would happen where > there was nothing handling for the case if my $ini = undef. If I > added the check to confirm $ini is defined prior to using it then > the error from Perl disappeared. The Perl error was Can't call > method ‘val’ on an undefined value... I have provided the following > sample code to fix the issue. > > sub _load { > my $self = shift; > my $ini = Config::IniFiles->new( -file => $self->{path} ); > > foreach my $type (qw/URL Modified IconFile IconIndex/) { > if (defined $ini){ > $self->{lc($type)} = $ini->val('InternetShortcut',$type) || > ''; > } else { > $self->{lc($type)} = ''; > } > } > $self->{cached} = 1; > } > > Thank you for writing this code in the first place. > > Regards > > Sam