View Issue Details

IDProjectCategoryView StatusLast Update
0000618fileGeneralpublic2025-01-30 18:43
Reportervinc17 Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version5.45 
Fixed in VersionHEAD 
Summary0000618: Arbitrary file starting with "%!" misidentified as PostScript document text
DescriptionAny file starting with "%!" is identified as PostScript document text, even files that are not PostScript, which is wrong.
Steps To Reproduce$ echo '%!' | file -
/dev/stdin: PostScript document text
Additional InformationI found this issue on a LaTeX file starting with

%!TEX root = rapport-Aric.tex

Such a line syntax seems to be used by some tools:
https://tex.stackexchange.com/questions/148649/tex-root-to-parent-directory
TagsNo tags attached.

Activities

vinc17

2025-01-28 13:12

reporter   ~0004163

I've just seen that there is an existing bug in the Debian BTS (reported in 2021):
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=988451

There, Hilmar Preuße says:
> The file too starts with "%!". According to [1] the magic byte for Postscript is "%!PS". So the check is not strict enough to rule out false positives.

vinc17

2025-01-28 14:31

reporter   ~0004164

The fix is to change "%!" to "%!PS" in the magic/Magdir/printer file. I've attached a patch I've written (for the Debian package).
file-postscript.patch (599 bytes)   
Description: Stricter PostScript magic
Bug-Debian: https://bugs.debian.org/988451
Bug: https://bugs.astron.com/view.php?id=618
Author: Vincent Lefevre <vincent@vinc17.net>
Last-Update: 2025-01-28

Index: b/magic/Magdir/printer
===================================================================
--- a/magic/Magdir/printer
+++ b/magic/Magdir/printer
@@ -5,7 +5,7 @@
 #
 
 # PostScript, updated by Daniel Quinlan (quinlan@yggdrasil.com)
-0	string		%!		PostScript document text
+0	string		%!PS		PostScript document text
 !:mime	application/postscript
 !:apple	ASPSTEXT
 >2	string		PS-Adobe-	conforming
file-postscript.patch (599 bytes)   

christos

2025-01-30 18:43

manager   ~0004169

Added magic for %!TEX\040root

Issue History

Date Modified Username Field Change
2025-01-28 12:57 vinc17 New Issue
2025-01-28 13:12 vinc17 Note Added: 0004163
2025-01-28 14:31 vinc17 Note Added: 0004164
2025-01-28 14:31 vinc17 File Added: file-postscript.patch
2025-01-30 18:42 christos Assigned To => christos
2025-01-30 18:42 christos Status new => assigned
2025-01-30 18:43 christos Status assigned => resolved
2025-01-30 18:43 christos Resolution open => fixed
2025-01-30 18:43 christos Fixed in Version => HEAD
2025-01-30 18:43 christos Note Added: 0004169