]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/filecheck/discussion.mdwn
54b14c18378328b7e97ebe35fafbde5ecdf4b9ea
[ikiwiki.git] / doc / plugins / filecheck / discussion.mdwn
1 First, thanks again for making this plugin.
2
3 I don't know if this is a problem for [[plugins/attachment]], but there seems to
4 be no way to detect text/plain using File::MimeInfo::Magic::magic().
5 There is a heuristic ::default that decides between text/plain and application/octet-stream.  
6
7 Would you be receptive to a patch that e.g. called File::MimeInfo::Magic::default()
8 if ::magic() returns undef?  --[[DavidBremner]]
9
10 > Yes, that looks to be ok. --[[Joey]]
11
12 >> OK, here is such a patch. One modification of previous behaviour is that 
13 >> that if default returns undef, this is returned. As far as I understand
14 >> the code/doc for File::MimeInfo, under is used only as an error return
15 >> for ::default
16 <pre>
17 From 84f40d7fa822c6cc09506cca2dbf38a8b19f8bb7 Mon Sep 17 00:00:00 2001
18 From: David Bremner <bremner@unb.ca>
19 Date: Fri, 29 Aug 2008 20:46:20 -0300
20 Subject: [PATCH] call File::MimeInfo::default if ::magic() returns undef
21
22 ---
23  IkiWiki/Plugin/filecheck.pm |    2 +-
24  1 files changed, 1 insertions(+), 1 deletions(-)
25
26 diff --git a/IkiWiki/Plugin/filecheck.pm b/IkiWiki/Plugin/filecheck.pm
27 index 9c7a8db..a94c02b 100644
28 --- a/IkiWiki/Plugin/filecheck.pm
29 +++ b/IkiWiki/Plugin/filecheck.pm
30 @@ -127,7 +127,7 @@ sub match_mimetype ($$;@) { #{{{
31         }
32         my $mimetype=File::MimeInfo::Magic::magic($file);
33         if (! defined $mimetype) {
34 -               $mimetype="unknown";
35 +               $mimetype=File::MimeInfo::Magic::default($file);
36         }
37
38         my $regexp=IkiWiki::glob2re($wanted);
39 --
40 1.5.6.3
41 </pre>