1 When uploading a PNG file on the wiki, through the webinterface or anonymous git, i get:
3 icon.png prohibited by allowed_attachments (file MIME type is application/octet-stream, not application/vnd.oasis.opendocument.*)
5 `attachment_allowed_attachments` is set to:
7 virusfree() and (mimetype(image/*) or mimetype(text/*) or mimetype(application/x-gzip) or mimetype(application/vnd.oasis.opendocument.*)) and maxsize(2048kb)
9 Maybe a bug in the [[plugins/filecheck]] plugin?
11 This is ikiwiki 3.20130904.1~bpo70+1 on Debian wheezy, with some patches applied, namely:
13 * [[todo/option_to_send_only_the_diff_in_notifyemail]]
14 * [[bugs/syslog_fails_with_non-ASCII_wikinames]]
15 * [[bugs/notifyemail_fails_with_some_openid_providers]]
16 * [[bugs/crashes_in_the_python_proxy_even_if_disabled]]
18 Weird... --[[anarcat]]
20 > Well, the pagespec seems to be matching correctly, given that it thinks the mime type is application/octet-stream.
21 > If File::MimeInfo::Magic is installed, ikiwiki uses it. If not, or if it fails to find any mime type, it falls back to using `file -bi`,
22 > and if that fails, it falls back to a default of application/octet-stream. --[[Joey]]
24 > > File::MimeInfo::Magic is installed:
26 > > ii libfile-mimeinfo-perl 0.16-1 all Perl module to determine file types
28 > > it turns out there's (still) a problem with the way we use the module. This test code:
30 > > #!/usr/bin/perl -w
31 > > my $file='icon.png';
32 > > use File::MimeInfo::Magic;
33 > > print "mime::magic: " . File::MimeInfo::Magic::magic($file) . "\n";
34 > > print "mime::default: " . File::MimeInfo::Magic::default($file) . "\n";
38 > > mime::magic: image/png
39 > > mime::default: application/octet-stream
41 > > `file -ib` returns the right thing (`image/png; charset=binary`).
43 > > So it *should* work: it seems that the `::default` code kicks in even if the `::magic` one actually works.
45 > > I have traced down the problem to this block of code:
47 > > if (! defined $mimetype || $mimetype !~s /;.*//) {
48 > > # Fall back to default value.
49 > > $mimetype=File::MimeInfo::Magic::default($file)
51 > > If you take a look deeply, this will fire up the default if there's no semicolon in the mimetype, which is expected for `file` calls, but not for `::magic()` calls. So `::magic()` works, but then the `::default` kicks in anyways.
53 > > [[!template id=gitbranch branch=anarcat/dev/magic-fails author="[[anarcat]]"]]
55 > > I have a stupid [[patch]] in my git repo which just appends a semicolon to the `::magic()` output, but maybe this should be done in another way...
59 > > > If the regex match isn't necessary and it's just about deleting the
60 > > > parameters, I think I'd prefer something like
62 > > > if (! defined $mimetype) {
65 > > > $mimetype =~ s/;.*//;
67 > > > but I'd be hesitant to do that without knowing why Joey implemented it
68 > > > the way it is. If it's about catching a result from file(1) that
69 > > > is not, in fact, a MIME type at all (empty string or error message
70 > > > or something), maybe something more like this?
72 > > > if (! defined $mimetype || $mimetype !~ s{[-\w]+/[-\w]+(?:;.*)?}{})
74 > > > (or whatever the allowed characters in MIME types are). --[[smcv]]
76 > > > > I don't mind either way, but i feel this should be fixed for the next release, as I need to reapply this patch at every upgrade now. -- [[anarcat]]
78 > > > > > This is still a problem in 3.20140831. -- [[anarcat]]