Skip Menu |

This queue is for tickets about the File-MMagic CPAN distribution.

Report information
The Basics
Id: 109673
Status: resolved
Priority: 0/
Queue: File-MMagic

People
Owner: KNOK [...] cpan.org
Requestors: me [...] eboxr.com
Cc:
AdminCc:

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



Subject: Redundant argument in sprintf from magicMatch
Redundant argument in sprintf at File/MMagic.pm line 932 in File::MMagic::magicMatch this is happening when using File::MMagic with warnings enabled on perl522 steps to reproduce Show quoted text
> perl522 -MFile::MMagic -w -e 'File::MMagic->new()->checktype_filename("icon.png")'
Redundant argument in sprintf at /usr/local/cpanel/3rdparty/perl/522/lib/perl5/cpanel_lib/File/MMagic.pm line 933. suggested patch [patch] diff --git a/modules/File-MMagic/File-MMagic/MMagic.pm b/modules/File-MMagic/File-MMagic/MMagic.pm index 538416c..68f8a24 100644 --- a/modules/File-MMagic/File-MMagic/MMagic.pm +++ b/modules/File-MMagic/File-MMagic/MMagic.pm @@ -925,11 +925,11 @@ sub magicMatch { # sprintf doesn't insert a backspace. if it's at the # beginning (typical) then don't include separator space. if ($message =~ s/^\\b//) { - $$p_desc .= sprintf($message,$data); + $$p_desc .= index($message, '%') >= 0 ? sprintf($message, $data) : $message; } else { # $$p_desc .= ' ' . sprintf($message,$data) if $message; - $$p_desc .= sprintf($message,$data) if $message; + $$p_desc .= index($message, '%') >= 0 ? sprintf($message, $data) : $message if $message; } my $subtest;
note that patch is incomplete as there are 2 extra usage of sprintf in magicMatchStr that need the same patch On Wed Nov 25 13:35:55 2015, atoomic wrote: Show quoted text
> Redundant argument in sprintf at File/MMagic.pm line 932 in > File::MMagic::magicMatch > this is happening when using File::MMagic with warnings enabled on > perl522 > > steps to reproduce >
> > perl522 -MFile::MMagic -w -e 'File::MMagic->new()-
> > >checktype_filename("icon.png")'
> Redundant argument in sprintf at > /usr/local/cpanel/3rdparty/perl/522/lib/perl5/cpanel_lib/File/MMagic.pm > line 933. > > suggested patch > > [patch] > diff --git a/modules/File-MMagic/File-MMagic/MMagic.pm b/modules/File- > MMagic/File-MMagic/MMagic.pm > index 538416c..68f8a24 100644 > --- a/modules/File-MMagic/File-MMagic/MMagic.pm > +++ b/modules/File-MMagic/File-MMagic/MMagic.pm > @@ -925,11 +925,11 @@ sub magicMatch { > # sprintf doesn't insert a backspace. if it's at the > # beginning (typical) then don't include separator space. > if ($message =~ s/^\\b//) { > - $$p_desc .= sprintf($message,$data); > + $$p_desc .= index($message, '%') >= 0 ? sprintf($message, > $data) : $message; > } > else { > # $$p_desc .= ' ' . sprintf($message,$data) if $message; > - $$p_desc .= sprintf($message,$data) if $message; > + $$p_desc .= index($message, '%') >= 0 ? sprintf($message, > $data) : $message if $message; > } > > my $subtest;
Thank you for you report. I fixed in the svn trunk. http://cvs.namazu.org/Subversion/MMagic/trunk/MMagic.pm?r1=290&r2=292