Description of problem: /usr/lib/node_modules/yarn/bin/yarn.js and other JavaScript files used to be detected as application/javascript in Fedora 34/35, but are detected as text/plain in Fedora 36. Version-Release number of selected component: file-5.41-1.fc36.x86_64 How reproducible: Easy Steps to Reproduce: 1. mock -r fedora-36-x86_64 install yarnpkg file 2. mock -r fedora-36-x86_64 shell 3. file --mime-type /usr/lib/node_modules/yarn/bin/yarn.js (You can also repeat with fedora-35-x86_64 for comparison.) Actual results: /usr/lib/node_modules/yarn/bin/yarn.js: text/plain Expected results: /usr/lib/node_modules/yarn/bin/yarn.js: application/javascript Additional info: I see no relevant notice in https://fossies.org/linux/misc/file-5.41.tar.gz/file-5.41/ChangeLog so I assume this is a regression.
This regression was introduced with file-5.41-1.fc36, in file-5.40-9.fc35 JavaScript detection works as expected. The problematic commit & line is https://github.com/file/file/commit/c07b2a18eb1c5d3854e3ecc72319a2336e361d9e#diff-85466710385fb2ac02303e18020a937c563abbea6d4050ba3aff96cf6c8e6866R100 This "wild-card match for interpreters" powerful (with huge strength) pattern is cause of the regression. After running file --checking-printout --list: 100: > 0 string/wt,=#! ,"a"] <-- used detection pattern 101: >> 1 string,x,"%s script text executable"] ... 16: > 0 search/1,=#!/usr/bin/env nodejs,"Node.js script text executable"] <-- expected detection pattern I'm going to ask the upstream about the proper fix for this - whether to increase the strength of the JavaScript detection patterns or to remove the "wild-card match for interpreters" pattern...
upstream commit: https://github.com/file/file/commit/f687fa2b92cd923173126614516c1d07894affb3 dist-git commit: https://src.fedoraproject.org/rpms/file/c/0be129eb878837a656b8a990295103d446be01c9
That was fast. Thanks!