X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/474b6524e0fe4b4bb3402bf6551bf97be7f3ee1f..305c91ccfb8776cde2a6dca0caeec26aa1f711ad:/IkiWiki/Plugin/filecheck.pm?ds=sidebyside diff --git a/IkiWiki/Plugin/filecheck.pm b/IkiWiki/Plugin/filecheck.pm index a78058ffe..6e6528398 100644 --- a/IkiWiki/Plugin/filecheck.pm +++ b/IkiWiki/Plugin/filecheck.pm @@ -48,7 +48,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, - section => "misc", }, } @@ -140,7 +139,7 @@ sub match_mimetype ($$;@) { my $mimeinfo_ok=! $@; my $mimetype; if ($mimeinfo_ok) { - my $mimetype=File::MimeInfo::Magic::magic($file); + $mimetype=File::MimeInfo::Magic::magic($file); } # Fall back to using file, which has a more complete @@ -148,9 +147,10 @@ sub match_mimetype ($$;@) { if (! defined $mimetype) { open(my $file_h, "-|", "file", "-bi", $file); $mimetype=<$file_h>; + chomp $mimetype; close $file_h; } - if (! defined $mimetype || $mimetype !~s /;.*//) { + if (! defined $mimetype) { # Fall back to default value. $mimetype=File::MimeInfo::Magic::default($file) if $mimeinfo_ok; @@ -158,9 +158,11 @@ sub match_mimetype ($$;@) { $mimetype="unknown"; } } + # Ignore any parameters, we only want the type itself + $mimetype =~ s/;.*//; my $regexp=IkiWiki::glob2re($wanted); - if ($mimetype!~/^$regexp$/i) { + if ($mimetype!~$regexp) { return IkiWiki::FailReason->new("file MIME type is $mimetype, not $wanted"); } else {