Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#931300: mime-support: update-mime incorrectly handles MimeType containing empty elements

6 views
Skip to first unread message

Alex Riesen

unread,
Jul 1, 2019, 3:10:03 AM7/1/19
to
Package: mime-support
Version: 3.60
Severity: minor

Dear Maintainer,

I noticed a strange entry in /etc/mailcap:

application/x-ext-cb7; evince %s; test=test -n "$DISPLAY"
; evince %s; test=test -n "$DISPLAY"
application/oxps; evince %s; test=test -n "$DISPLAY"

After a bit of investigation, it turned out that generation of the entry has
been triggered by an empty item in evince.desktop (evince 3.22.1-3+deb9u1) file:

MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf;application/x-ext-pdf;application/postscript;application/x-bzpostscript;application/x-gzpostscript;image/x-eps;image/x-bzeps;image/x-gzeps;application/x-ext-ps;application/x-ext-eps;application/x-dvi;application/x-bzdvi;application/x-gzdvi;application/x-ext-dvi;image/vnd.djvu;image/vnd.djvu+multipage;application/x-ext-djv;application/x-ext-djvu;image/tiff;application/x-cbr;application/x-cbz;application/x-cb7;application/x-ext-cbr;application/x-ext-cbz;application/vnd.comicbook+zip;application/x-ext-cb7;;application/oxps;application/vnd.ms-xpsdocument;

Correcting the desktop file to have only full types in the list obviously
fixed the mailcap, but I wonder if instead of correcting desktop files (or in
addition to) the update-mime should filter out such entries from MimeType?

For instance (diff against 3.62 from unstable, fits 3.60 too):

diff --git a/update-mime b/update-mime
index d27b8a9..be4187f 100755
--- a/update-mime
+++ b/update-mime
@@ -157,7 +157,7 @@ sub ReadDesktopEntries
$exec .= " %s" if ($exec !~ m/%s/);
}
elsif (m/MimeType=(.*)/i) {
- push @types, split(/;/, $1);
+ push @types, grep {length>0} split(/\s*;\s*/, $1);
}
}
if (!defined($exec) || !scalar(@types)) {

Regards,
Alex

-- System Information:
Debian Release: 9.9
APT prefers stable-debug
APT policy: (500, 'stable-debug'), (500, 'proposed-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.1.15 (SMP w/8 CPU cores; PREEMPT)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

mime-support depends on no packages.

Versions of packages mime-support recommends:
ii bzip2 1.0.6-8.1
ii file 1:5.30-1+deb9u2
ii xz-utils 5.2.2-1.2+b1

mime-support suggests no packages.

-- no debconf information

Charles Plessy

unread,
Jul 1, 2019, 9:40:03 AM7/1/19
to
Le Mon, Jul 01, 2019 at 09:05:36AM +0200, Alex Riesen a écrit :
>
> diff --git a/update-mime b/update-mime
> index d27b8a9..be4187f 100755
> --- a/update-mime
> +++ b/update-mime
> @@ -157,7 +157,7 @@ sub ReadDesktopEntries
> $exec .= " %s" if ($exec !~ m/%s/);
> }
> elsif (m/MimeType=(.*)/i) {
> - push @types, split(/;/, $1);
> + push @types, grep {length>0} split(/\s*;\s*/, $1);
> }
> }
> if (!defined($exec) || !scalar(@types)) {

Dear Alex,

thank you for the report and for the patch.

Do you think it would make sense to throw a warning on stderr when such
a broken entry is found ? In that case, would you have time to propose
an updated patch ?

Have a nice day,

Charles

--
Charles Plessy
Akano, Uruma, Okinawa, Japan

Charles Plessy

unread,
Jul 1, 2019, 9:40:03 AM7/1/19
to
Control: clone -1
Control: reassign -1 evince
Control: retitle -1 evince: broken Desktop entry file in Stable
Control: found -1 3.22.1-3+deb9u1
Control: notfound -1 3.30.2-3

Dear Evince maintainers,

evince in Stable contains a broken Desktop file that causes mime-support
to produce a broken mailcap file:

Le Mon, Jul 01, 2019 at 09:05:36AM +0200, Alex Riesen a écrit :
> Package: mime-support
> Version: 3.60
> Severity: minor
>
> I noticed a strange entry in /etc/mailcap:
>
> application/x-ext-cb7; evince %s; test=test -n "$DISPLAY"
> ; evince %s; test=test -n "$DISPLAY"
> application/oxps; evince %s; test=test -n "$DISPLAY"
>
> After a bit of investigation, it turned out that generation of the entry has
> been triggered by an empty item in evince.desktop (evince 3.22.1-3+deb9u1) file:
>
> MimeType=application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf;application/x-ext-pdf;application/postscript;application/x-bzpostscript;application/x-gzpostscript;image/x-eps;image/x-bzeps;image/x-gzeps;application/x-ext-ps;application/x-ext-eps;application/x-dvi;application/x-bzdvi;application/x-gzdvi;application/x-ext-dvi;image/vnd.djvu;image/vnd.djvu+multipage;application/x-ext-djv;application/x-ext-djvu;image/tiff;application/x-cbr;application/x-cbz;application/x-cb7;application/x-ext-cbr;application/x-ext-cbz;application/vnd.comicbook+zip;application/x-ext-cb7;;application/oxps;application/vnd.ms-xpsdocument;

Indeed, desktop-file-validate rejects this entry:

desktop-file-validate /usr/share/applications/evince.desktop
/usr/share/applications/evince.desktop: hint: value "GNOME;GTK;Office;Viewer;Graphics;2DGraphics;VectorGraphics;" for key "Categories" in group "Desktop Entry" contains more than one main category; application might appear more than once in the application menu
/usr/share/applications/evince.desktop: error: (will be fatal in the future): value "application/pdf;application/x-bzpdf;application/x-gzpdf;application/x-xzpdf;application/x-ext-pdf;application/postscript;application/x-bzpostscript;application/x-gzpostscript;image/x-eps;image/x-bzeps;image/x-gzeps;application/x-ext-ps;application/x-ext-eps;application/x-dvi;application/x-bzdvi;application/x-gzdvi;application/x-ext-dvi;image/vnd.djvu;image/vnd.djvu+multipage;application/x-ext-djv;application/x-ext-djvu;image/tiff;application/x-cbr;application/x-cbz;application/x-cb7;application/x-ext-cbr;application/x-ext-cbz;application/vnd.comicbook+zip;application/x-ext-cb7;;application/oxps;application/vnd.ms-xpsdocument;" for key "MimeType" in group "Desktop Entry" contains value "" which is an invalid MIME type: "" does not contain a subtype

I am not sure if this warrants a stable update, but at least I wanted to let you know the issue.

Have a nice day,

Charles

--
Charles Plessy
http://www.debian.org/devel/debian-med
Akano, Uruma, Okinawa, Japan

Charles Plessy

unread,
Jul 1, 2019, 9:50:03 AM7/1/19
to
Control: clone 931300 -1
Control: reassign 931300 mime-support
Control: retile 931300 mime-support: update-mime incorrectly handles MimeType containing empty elements
Control: found 931300 3.60

Le Mon, Jul 01, 2019 at 10:21:24PM +0900, Charles Plessy a écrit :
> Control: clone -1
> Control: reassign -1 evince
> Control: retitle -1 evince: broken Desktop entry file in Stable
> Control: found -1 3.22.1-3+deb9u1
> Control: notfound -1 3.30.2-3
>
> Dear Evince maintainers,

Sorry for the noise...

--
Charles

Alex Riesen

unread,
Jul 1, 2019, 10:00:03 AM7/1/19
to
Charles Plessy, Mon, Jul 01, 2019 15:26:03 +0200:
> Le Mon, Jul 01, 2019 at 09:05:36AM +0200, Alex Riesen a écrit :
> >
> > elsif (m/MimeType=(.*)/i) {
> > - push @types, split(/;/, $1);
> > + push @types, grep {length>0} split(/\s*;\s*/, $1);
>
> Do you think it would make sense to throw a warning on stderr when such
> a broken entry is found ? In that case, would you have time to propose
> an updated patch ?

Of course. Like the below, perhaps? (I still filter them out).

Regards,
Alex


diff --git a/update-mime b/update-mime
index d27b8a9..55495ee 100755
--- a/update-mime
+++ b/update-mime
@@ -157,7 +157,10 @@ sub ReadDesktopEntries
$exec .= " %s" if ($exec !~ m/%s/);
}
elsif (m/MimeType=(.*)/i) {
- push @types, split(/;/, $1);
+ my $err = 0;
+ push @types, grep { if (length>0) {1} else {++$err;0} }
+ split(/\s*;\s*/, $1);
+ print STDERR "Warning: $file:$.: ignoring empty entries in MimeType\n" if $err;
}
}
if (!defined($exec) || !scalar(@types)) {

Charles Plessy

unread,
Jul 3, 2019, 9:10:04 AM7/3/19
to
Le Mon, Jul 01, 2019 at 03:52:47PM +0200, Alex Riesen a écrit :
>
> diff --git a/update-mime b/update-mime
> index d27b8a9..55495ee 100755
> --- a/update-mime
> +++ b/update-mime
> @@ -157,7 +157,10 @@ sub ReadDesktopEntries
> $exec .= " %s" if ($exec !~ m/%s/);
> }
> elsif (m/MimeType=(.*)/i) {
> - push @types, split(/;/, $1);
> + my $err = 0;
> + push @types, grep { if (length>0) {1} else {++$err;0} }
> + split(/\s*;\s*/, $1);
> + print STDERR "Warning: $file:$.: ignoring empty entries in MimeType\n" if $err;
> }
> }
> if (!defined($exec) || !scalar(@

Thanks a lot. I suppose you do not mind your name and email appearing
in the commit or in the package's changelog ? The commit would be as
follows:

commit 21035f879b53416df6c7f74720c6ff4da3e1f94a
Author: Alex Riesen <alexande...@cetitec.com>
Date: Wed Jul 3 21:54:55 2019 +0900

update-mime: softly reject empty media types

Closes: #931300
Signed-off-by: Charles Plessy <ple...@debian.org>

I will only upload the package after the end of the Freeze, hopefully soon :)

Alex Riesen

unread,
Jul 3, 2019, 9:20:02 AM7/3/19
to
Charles Plessy, Wed, Jul 03, 2019 14:59:42 +0200:
> Le Mon, Jul 01, 2019 at 03:52:47PM +0200, Alex Riesen a écrit :
> >
> > diff --git a/update-mime b/update-mime
>
> Thanks a lot. I suppose you do not mind your name and email appearing
> in the commit or in the package's changelog ? ...

I don't. Glad I could help!

Regards,
Alex
0 new messages