Magic for text/x-tex broken

Bug #1485217 reported by Jan Philipp Wächter
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
shared-mime-info (Ubuntu)
Fix Released
High
Unassigned

Bug Description

The magic for text/x-tex in Ubuntu 15.04 is broken as it assigns text/x-tex to any text file which contains the word "section", "chapter" or "documentclass" within the first 100 characters.

This behavior is fixed if one adds backslashes to the appropriate match values in /usr/share/mime/packages/freedesktop.org.xml (.in) (see attached patch).

Edit: You can reproduce this bug as follows.

Is (output on Ubuntu 15.04):
user@host:/tmp/mime$ dpkg -s shared-mime-info | grep "Version"
Version: 1.3-1
user@host:/tmp/mime$ sed '30568,30638!d' /usr/share/mime/packages/freedesktop.org.xml
  <mime-type type="text/x-tex">
    <comment>TeX document</comment>
    <comment xml:lang="ar">مستند TeX</comment>
    <comment xml:lang="be@latin">Dakument TeX</comment>
    <comment xml:lang="bg">Документ — TeX</comment>
    <comment xml:lang="ca">document TeX</comment>
    <comment xml:lang="cs">Dokument TeX</comment>
    <comment xml:lang="cy">Dogfen TeX </comment>
    <comment xml:lang="da">TeX-dokument</comment>
    <comment xml:lang="de">TeX-Dokument</comment>
    <comment xml:lang="el">έγγραφο TeX</comment>
    <comment xml:lang="en_GB">TeX document</comment>
    <comment xml:lang="eo">TeX-dokumento</comment>
    <comment xml:lang="es">documento TeX</comment>
    <comment xml:lang="eu">TeX dokumentua</comment>
    <comment xml:lang="fi">TeX-asiakirja</comment>
    <comment xml:lang="fo">TeX skjal</comment>
    <comment xml:lang="fr">document TeX</comment>
    <comment xml:lang="ga">cáipéis TeX</comment>
    <comment xml:lang="gl">documenton TeX</comment>
    <comment xml:lang="he">מסמך TeX</comment>
    <comment xml:lang="hr">TeX dokument</comment>
    <comment xml:lang="hu">TeX-dokumentum</comment>
    <comment xml:lang="id">Dokumen TeX</comment>
    <comment xml:lang="it">Documento TeX</comment>
    <comment xml:lang="ja">TeX ドキュメント</comment>
    <comment xml:lang="kk">TeX құжаты</comment>
    <comment xml:lang="ko">TeX 문서</comment>
    <comment xml:lang="lt">TeX dokumentas</comment>
    <comment xml:lang="lv">TeX dokuments</comment>
    <comment xml:lang="ms">Dokumen TeX</comment>
    <comment xml:lang="nb">TeX-dokument</comment>
    <comment xml:lang="nl">TeX-document</comment>
    <comment xml:lang="nn">TeX-dokument</comment>
    <comment xml:lang="pl">Dokument TeX</comment>
    <comment xml:lang="pt">documento TeX</comment>
    <comment xml:lang="pt_BR">Documento TeX</comment>
    <comment xml:lang="ro">Document TeX</comment>
    <comment xml:lang="ru">документ TeX</comment>
    <comment xml:lang="sk">Dokument TeX</comment>
    <comment xml:lang="sl">Dokument TeX</comment>
    <comment xml:lang="sq">Dokument TeX</comment>
    <comment xml:lang="sr">ТеХ документ</comment>
    <comment xml:lang="sv">TeX-dokument</comment>
    <comment xml:lang="tr">TeX belgesi</comment>
    <comment xml:lang="uk">документ TeX</comment>
    <comment xml:lang="vi">Tài liệu TeX</comment>
    <comment xml:lang="zh_CN">TeX 文档</comment>
    <comment xml:lang="zh_TW">TeX 文件</comment>
    <sub-class-of type="text/plain"/>
    <alias type="application/x-tex"/>
    <glob pattern="*.tex"/>
    <glob pattern="*.ltx"/>
    <glob pattern="*.sty"/>
    <glob pattern="*.cls"/>
    <glob pattern="*.dtx"/>
    <glob pattern="*.ins"/>
    <glob pattern="*.latex"/>
    <magic priority="10">
      <match value="%" type="string" offset="0"/>
    </magic>
    <magic priority="50">
      <match value="\documentclass" type="string" offset="0:100"/>
    </magic>
    <magic priority="50">
      <match value="\chapter" type="string" offset="0:100"/>
    </magic>
    <magic priority="50">
      <match value="\section" type="string" offset="0:100"/>
    </magic>
  </mime-type>
user@host:/tmp/mime$ echo "Normal text using 'sectional'." > no_tex
user@host:/tmp/mime$ mimetype no_tex
no_tex: text/x-tex
user@host:/tmp/mime$ echo "\section{A \TeX Section}" > tex_file.tex
user@host:/tmp/mime$ mimetype tex_file.tex
tex_file.tex: text/x-tex

Should (is, after patching):
user@host:/tmp/mime$ sed '30568,30638!d' /usr/share/mime/packages/freedesktop.org.xml
  <mime-type type="text/x-tex">
    <comment>TeX document</comment>
    <comment xml:lang="ar">مستند TeX</comment>
    <comment xml:lang="be@latin">Dakument TeX</comment>
    <comment xml:lang="bg">Документ — TeX</comment>
    <comment xml:lang="ca">document TeX</comment>
    <comment xml:lang="cs">Dokument TeX</comment>
    <comment xml:lang="cy">Dogfen TeX </comment>
    <comment xml:lang="da">TeX-dokument</comment>
    <comment xml:lang="de">TeX-Dokument</comment>
    <comment xml:lang="el">έγγραφο TeX</comment>
    <comment xml:lang="en_GB">TeX document</comment>
    <comment xml:lang="eo">TeX-dokumento</comment>
    <comment xml:lang="es">documento TeX</comment>
    <comment xml:lang="eu">TeX dokumentua</comment>
    <comment xml:lang="fi">TeX-asiakirja</comment>
    <comment xml:lang="fo">TeX skjal</comment>
    <comment xml:lang="fr">document TeX</comment>
    <comment xml:lang="ga">cáipéis TeX</comment>
    <comment xml:lang="gl">documenton TeX</comment>
    <comment xml:lang="he">מסמך TeX</comment>
    <comment xml:lang="hr">TeX dokument</comment>
    <comment xml:lang="hu">TeX-dokumentum</comment>
    <comment xml:lang="id">Dokumen TeX</comment>
    <comment xml:lang="it">Documento TeX</comment>
    <comment xml:lang="ja">TeX ドキュメント</comment>
    <comment xml:lang="kk">TeX құжаты</comment>
    <comment xml:lang="ko">TeX 문서</comment>
    <comment xml:lang="lt">TeX dokumentas</comment>
    <comment xml:lang="lv">TeX dokuments</comment>
    <comment xml:lang="ms">Dokumen TeX</comment>
    <comment xml:lang="nb">TeX-dokument</comment>
    <comment xml:lang="nl">TeX-document</comment>
    <comment xml:lang="nn">TeX-dokument</comment>
    <comment xml:lang="pl">Dokument TeX</comment>
    <comment xml:lang="pt">documento TeX</comment>
    <comment xml:lang="pt_BR">Documento TeX</comment>
    <comment xml:lang="ro">Document TeX</comment>
    <comment xml:lang="ru">документ TeX</comment>
    <comment xml:lang="sk">Dokument TeX</comment>
    <comment xml:lang="sl">Dokument TeX</comment>
    <comment xml:lang="sq">Dokument TeX</comment>
    <comment xml:lang="sr">ТеХ документ</comment>
    <comment xml:lang="sv">TeX-dokument</comment>
    <comment xml:lang="tr">TeX belgesi</comment>
    <comment xml:lang="uk">документ TeX</comment>
    <comment xml:lang="vi">Tài liệu TeX</comment>
    <comment xml:lang="zh_CN">TeX 文档</comment>
    <comment xml:lang="zh_TW">TeX 文件</comment>
    <sub-class-of type="text/plain"/>
    <alias type="application/x-tex"/>
    <glob pattern="*.tex"/>
    <glob pattern="*.ltx"/>
    <glob pattern="*.sty"/>
    <glob pattern="*.cls"/>
    <glob pattern="*.dtx"/>
    <glob pattern="*.ins"/>
    <glob pattern="*.latex"/>
    <magic priority="10">
      <match value="%" type="string" offset="0"/>
    </magic>
    <magic priority="50">
      <match value="\\documentclass" type="string" offset="0:100"/>
    </magic>
    <magic priority="50">
      <match value="\\chapter" type="string" offset="0:100"/>
    </magic>
    <magic priority="50">
      <match value="\\section" type="string" offset="0:100"/>
    </magic>
  </mime-type>
user@host:/tmp/mime$ echo "Normal text using 'sectional'." > no_tex
user@host:/tmp/mime$ mimetype no_tex
no_tex: text/plain
user@host:/tmp/mime$ echo "\section{A \TeX Section}" > tex_file.tex
user@host:/tmp/mime$ mimetype tex_file.tex
tex_file.tex: text/x-tex

Tags: patch
Revision history for this message
Jan Philipp Wächter (jan-waechter) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "fix_x-tex_magic.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Mathieu Trudel-Lapierre (cyphermox) wrote :

How are you reproducing this? How can I verify the fix?

It seems to me as nautilus recognizes a dummy file correctly as plain text rather than TeX document; so does the file command.

description: updated
Changed in shared-mime-info (Ubuntu):
status: New → Incomplete
Revision history for this message
Jan Philipp Wächter (jan-waechter) wrote :

Could you please elaborate on which additional information you need?

Using the commands given above, one can reproduce this bug.
I could also verify that it affects Ubuntu 14.04 LTS, too.

Revision history for this message
Sebastien Bacher (seb128) wrote :
Revision history for this message
Jan Philipp Wächter (jan-waechter) wrote :

The bug is now fixed in Debian upstream (revision 378, thanks to user "slomo"):
http://anonscm.debian.org/viewvc/pkg-freedesktop/trunk/shared-mime-info/debian/patches/061_tex-matlab.patch?view=log

It is not (and probably never was) present in the Freedesktop sources:
http://cgit.freedesktop.org/xdg/shared-mime-info/tree/freedesktop.org.xml.in

Revision history for this message
Sebastien Bacher (seb128) wrote :
Changed in shared-mime-info (Ubuntu):
importance: Undecided → High
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.