#1100642 File declared wrongly as a javascript

Package:
file
Source:
file
Description:
Recognize the type of data in a file using "magic" numbers
Submitter:
Bjarni Ingi Gislason
Date:
2025-03-18 19:57:02 UTC
Severity:
normal
Tags:
#1100642#5
Date:
2025-03-16 14:07:53 UTC
From:
To:
Dear Maintainer,

   * What led up to the situation?

Using the command "file" <file>

   * What exactly did you do (or not do) that was effective (or
     ineffective)?

file chk_man.err.import-im7.q16.1

   * What was the outcome of this action?

chk_man.err.import-im7.q16.1: JavaScript source, ASCII text, with very long
lines (314)

  * What outcome did you expect instead?

  Just ASCII text.

-.-

  The mailing agent "mutt" then encodes the file with base64.

  The file contains ascii text and a difference between man pages.

#1100642#10
Date:
2025-03-18 19:46:14 UTC
From:
To:
[ Adding FC ]

Bjarni Ingi Gislason wrote...

This is caused by a change upstream in commit

<https://github.com/file/file/commit/a2756aa50fdf7d87ebb14002ffd7609373ea6839>
| commit a2756aa50fdf7d87ebb14002ffd7609373ea6839
| Author: Christos Zoulas <christos@zoulas.com>
| Date:   Thu Jan 12 00:02:16 2023 +0000
|
|     Improve JavaScript detection (FC Stegerman)

@FC as you authored that: The triggering line is

| 0      regex   \^(import|export).*\x20from\x20 JavaScript source

and I was wondering whether there's a way to resolve this. As a first
attempt, checking for an extra space after import, i.e.

| 0      regex   \^(import|export)\x20.*\x20from\x20     JavaScript source

would do the trick. Or using a word boundary:

| 0      regex   \^(import|export)\b.*\x20from\x20       JavaScript source

Perhaps you could improve that, depending what you wwant to achieve and
what caused the initial rules?

    Christoph