diff options
author | Christos Zoulas <christos@zoulas.com> | 2023-01-12 00:02:16 +0000 |
---|---|---|
committer | Christos Zoulas <christos@zoulas.com> | 2023-01-12 00:02:16 +0000 |
commit | a2756aa50fdf7d87ebb14002ffd7609373ea6839 (patch) | |
tree | 6bc5c968c93a1167f450f7802e38ee9856987d69 | |
parent | bb955ca335d2f90ade1ed1ced239eb9ff8d9896d (diff) | |
download | file-git-a2756aa50fdf7d87ebb14002ffd7609373ea6839.tar.gz |
Improve JavaScript detection (FC Stegerman)
-rw-r--r-- | magic/Magdir/javascript | 64 | ||||
-rw-r--r-- | magic/Magdir/sgml | 12 |
2 files changed, 68 insertions, 8 deletions
diff --git a/magic/Magdir/javascript b/magic/Magdir/javascript index dcb5a937..90a09cce 100644 --- a/magic/Magdir/javascript +++ b/magic/Magdir/javascript @@ -1,20 +1,70 @@ #------------------------------------------------------------------------------ -# $File: javascript,v 1.4 2022/09/02 08:08:17 christos Exp $ +# $File: javascript,v 1.5 2023/01/12 00:02:16 christos Exp $ # javascript: magic for javascript and node.js scripts. # -0 string/w #!/bin/node Node.js script text executable +0 string/tw #!/bin/node Node.js script executable !:mime application/javascript -0 string/w #!/usr/bin/node Node.js script text executable +0 string/tw #!/usr/bin/node Node.js script executable !:mime application/javascript -0 string/w #!/bin/nodejs Node.js script text executable +0 string/tw #!/bin/nodejs Node.js script executable !:mime application/javascript -0 string/w #!/usr/bin/nodejs Node.js script text executable +0 string/tw #!/usr/bin/nodejs Node.js script executable !:mime application/javascript -0 string #!/usr/bin/env\ node Node.js script text executable +0 string/t #!/usr/bin/env\ node Node.js script executable !:mime application/javascript -0 string #!/usr/bin/env\ nodejs Node.js script text executable +0 string/t #!/usr/bin/env\ nodejs Node.js script executable !:mime application/javascript + +# JavaScript +# The strength is increased to beat the C++ & HTML rules +0 search "use\x20strict" JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 search 'use\x20strict' JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex module(\\.|\\[["'])exports.*= JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex \^(const|var|let).*=.*require\\( JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex \^export\x20(function|class|default|const|var|let|async)\x20 JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex \\((async\x20)?function[(\x20] JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex \^(import|export).*\x20from\x20 JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex \^(import|export)\x20["']\\./ JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex \^require\\(["'] JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js +0 regex typeof.*[!=]== JavaScript source +!:strength +30 +!:mime application/javascript +!:ext js + +# React Native minified JavaScript +0 search/128 __BUNDLE_START_TIME__= React Native minified JavaScript +!:strength +30 +!:mime application/javascript +!:ext bundle/jsbundle + # Hermes by Facebook https://hermesengine.dev/ # https://github.com/facebook/hermes/blob/master/include/hermes/\ # BCGen/HBC/BytecodeFileFormat.h#L24 diff --git a/magic/Magdir/sgml b/magic/Magdir/sgml index 71e2dab5..1677329b 100644 --- a/magic/Magdir/sgml +++ b/magic/Magdir/sgml @@ -1,6 +1,6 @@ #------------------------------------------------------------------------------ -# $File: sgml,v 1.46 2022/08/16 11:16:39 christos Exp $ +# $File: sgml,v 1.47 2023/01/12 00:02:16 christos Exp $ # Type: SVG Vectorial Graphics # From: Noel Torres <tecnico@ejerciciosresueltos.com> 0 string \<?xml\ version= @@ -50,6 +50,16 @@ !:mime text/html !:strength + 5 +# avoid misdetection as JavaScript +0 string/cWt \<!doctype\ html HTML document text +!:mime text/html +0 string/ct \<html> HTML document text +!:mime text/html +0 string/ct \<!-- +>&0 search/4096/cWt \<!doctype\ html HTML document text +>&0 search/4096/ct \<html> HTML document text +!:mime text/html + # SVG document # https://www.w3.org/TR/SVG/single-page.html 0 search/4096/cWbt \<!doctype\ svg SVG XML document |