Over-optimistic detection of file type

Bug #99736 reported by Tom Womack
4
Affects Status Importance Assigned to Milestone
shared-mime
Fix Released
Medium
shared-mime-info (Ubuntu)
Fix Released
Low
Unassigned

Bug Description

Binary package hint: nautilus

I have a text file which begins 'P13438 = 2 * 3 * 7 * 1047137401 * 8868717860281682366053088136263931781236052676953 * 37740643638981149828904962487908210028313437770048087043525652181' - it's a list of factorizations of partition numbers.

For some reason nautilus thinks this is a PBM image, and won't by default open it with gedit.

I think that files which claim to be text files should be opened with the text editor whether or not nautilus thinks they are text files.

Revision history for this message
In , Christophe Fergeau (teuf-gnome) wrote :

So, this was indeed a mismatch, I committed a fix to xdgmime CVS, but now it
will identify files beginning with P1 as portable bitmap files, I guess you
won't consider this bug as fixed in a satisfactory way :)

Revision history for this message
In , Bastien Nocera (hadess-deactivatedaccount) wrote :

$ echo "P1" > foo
$ file foo
foo: Netpbm PBM image text

Should we leave this bug opened?

Revision history for this message
Tom Womack (tom-womack) wrote :

Binary package hint: nautilus

I have a text file which begins 'P13438 = 2 * 3 * 7 * 1047137401 * 8868717860281682366053088136263931781236052676953 * 37740643638981149828904962487908210028313437770048087043525652181' - it's a list of factorizations of partition numbers.

For some reason nautilus thinks this is a PBM image, and won't by default open it with gedit.

I think that files which claim to be text files should be opened with the text editor whether or not nautilus thinks they are text files.

Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug. That's due to the shared-mime-info pbm definition

Changed in nautilus:
importance: Undecided → Low
status: Unconfirmed → Confirmed
Revision history for this message
In , Benjamin-close (benjamin-close) wrote :

Bugzilla Upgrade Mass Bug Change

NEEDSINFO state was removed in Bugzilla 3.x, reopening any bugs previously listed as NEEDSINFO.

  - benjsc
    fd.o Wrangler

Revision history for this message
In , Daniel Leidert (dleidert-deactivatedaccount) wrote :

(In reply to comment #0)
> I have a text file that begins with "TP1" (you can create one with just these
> three characters). When double-clicking on it in nautilus, it tells me that the
> filename suggests it's a text file but the file content suggests it's a portable
> bitmap file.

Hm. ATM in fast detection its detected as application/octet-stream by gnomevfs-info. If it would be detected as text/plain, then gnomevfs shouldn't detect it as image/x-portable-bitmap.

I'm not sure if the problem can be solved in the shared-mime-info database. IMO there are two alternatives: 1) remove the magic from image/x-portable-bitmap (no conflicting global pattern) or b) forward this to the upstream of gnomevfs and kdemime and check, if some better heuristics between text/plain and application/octet-stream can solve this problem.

Revision history for this message
In , Daniel Leidert (dleidert-deactivatedaccount) wrote :

Hm. After reading some more about the formats, it should also be possible to extend the graphics a bit to be

P1\x0a# (offset: 0)

so the magic includes the (possible) comment in line 2, although this comment is not required. But it is less generic than just searching for P1..7.

Revision history for this message
In , Sense Egbert Hofstede (sense) wrote :

This bug has also been reported in launchpad for PBM images by Tom Womack: https://bugs.edge.launchpad.net/ubuntu/+source/shared-mime-info/+bug/99736
He said:
"I have a text file which begins 'P13438 = 2 * 3 * 7 * 1047137401 * 8868717860281682366053088136263931781236052676953 * 37740643638981149828904962487908210028313437770048087043525652181' - it's a list of factorizations of partition numbers.

For some reason nautilus thinks this is a PBM image, and won't by default open it with gedit.

I think that files which claim to be text files should be opened with the text editor whether or not nautilus thinks they are text files."

Revision history for this message
Sense Egbert Hofstede (sense) wrote :

Comment added to the freedesktop bug tracker.

Changed in shared-mime:
status: New → Unknown
Changed in shared-mime:
status: Unknown → Confirmed
Changed in shared-mime-info:
status: Confirmed → Triaged
Revision history for this message
In , Bastien Nocera (hadess-deactivatedaccount) wrote :

(In reply to comment #5)
> Hm. After reading some more about the formats, it should also be possible to
> extend the graphics a bit to be
>
> P1\x0a# (offset: 0)
>
> so the magic includes the (possible) comment in line 2, although this comment
> is not required. But it is less generic than just searching for P1..7.

Seems like the best option. A magic of 2 characters is just too short...

* freedesktop.org.xml.in: Tighten the magic for PBM,
PPM and PGM types, so as to avoid false positives
(Closes: #2359)
* tests/list:
* tests/test.pbm: Add a pbm test file

Changed in shared-mime:
status: Confirmed → Fix Released
Revision history for this message
Sebastien Bacher (seb128) wrote :

the bug has been fixed upstream now

Changed in shared-mime-info:
status: Triaged → Fix Committed
Revision history for this message
Sebastien Bacher (seb128) wrote :

the bug is fixed in the intrepid version

Changed in shared-mime-info:
status: Fix Committed → Fix Released
Revision history for this message
In , Nunojsilva (nunojsilva) wrote :

Some image viewers, which rely on gtk+ to show images, are unable to show portable anymaps. gtk+ seems to rely on freedesktop.org.xml for file type detection, which fails for some anymaps.

Removing the lines about # solves this, and here "man 5 ppm" does not say a comment is needed (although it can exist).

Changed in shared-mime:
importance: Unknown → Medium
Changed in shared-mime:
importance: Medium → Unknown
Changed in shared-mime:
importance: Unknown → Medium
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.