[PATCH] JavaScript (and HTML) files containing "use strict" are misdetected as Perl files
Submitted by Dwayne Litzenberger
Assigned to Shared Mime Info group
Link to original bug (#105838)
Description
HTML and JavaScript files are sometimes being misdetected as Perl files, due to the following match rule for application/x-perl:
<match type="string" value="use strict" offset="0:256"/>
This is too broad. It incorrectly matches against ECMAScript's strict-mode syntax[1], which can look like one of the following lines (including quotes and semicolon):
"use strict";
'use strict';
This seems to have been introduced in commit a6bdb6a1 (shared-mime-info 1.2), which was related to bug 63612.
As a solution, I suggest to replace the above match rule with rules that will match the Perl syntax without matching the quote-surrounded JavaScript syntax:
<match type="string" value="use strict;" offset="0:256"/>
<match type="string" value="use strict " offset="0:256"/>
A patch will be attached to this bug.
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode