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;