#744924 buggy magic: mistakes text as diff when starting with "*** "

Package:
file
Source:
file
Description:
Recognize the type of data in a file using "magic" numbers
Submitter:
Vincent Lefevre
Date:
2020-11-21 17:27:05 UTC
Severity:
normal
Tags:
#744924#5
Date:
2014-04-16 10:46:46 UTC
From:
To:
The attached text file is regarded as "diff output" by file:

xvii:~> file out
out: diff output, ASCII text

#744924#10
Date:
2014-04-16 11:04:13 UTC
From:
To:
Control: retitle -1 buggy magic: mistakes text as diff when starting with "*** "
[...]

This happens when the file starts with "*** " (3 stars and a space).
Checking only for these 4 characters is just silly!

Two solutions:

1. Check that the second line starts with "--- " (possibly check the
third line as well, and this should be sufficient). See

https://en.wikipedia.org/wiki/Diff#Context_format

for an example.

2. If this is too complex, remove the support for this "context" diff
format, as it is more or less obsolete.

#744924#17
Date:
2016-07-17 23:17:27 UTC
From:
To:
tags 744924 upstream confirmed
thanks

Vincent Lefevre wrote...

That's bad indeed. Will try to come up with a solution soon.

    Christoph

#744924#30
Date:
2020-11-21 17:23:47 UTC
From:
To:
This bug is still there:

zira% file --version
file-5.39
magic file from /etc/magic:/usr/share/misc/magic
zira% echo '*** Title' | file -
/dev/stdin: diff output, ASCII text

The upstream bug https://bugs.astron.com/view.php?id=184 says that
it is fixed in 5.39. Is there anything specific to Debian?