From c4983ea61818ba079305571b68380890cc9f09b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=B5=20Tr=C6=B0=E1=BB=9Dng=20An?= <32063562+votruongan@users.noreply.github.com> Date: Sun, 26 Dec 2021 07:30:29 +0700 Subject: [PATCH] Add support for ELF (Unix Executable and Linkable Format) (#514) --- core.d.ts | 2 ++ core.js | 7 +++++++ fixture/fixture.elf | Bin 0 -> 142 bytes package.json | 1 + readme.md | 1 + supported.js | 2 ++ 6 files changed, 13 insertions(+) create mode 100644 fixture/fixture.elf diff --git a/core.d.ts b/core.d.ts index e15bf839..b437458a 100644 --- a/core.d.ts +++ b/core.d.ts @@ -49,6 +49,7 @@ export type FileExtension = | 'pdf' | 'epub' | 'mobi' + | 'elf' | 'exe' | 'swf' | 'rtf' @@ -195,6 +196,7 @@ export type MimeType = | 'audio/wavpack' | 'audio/amr' | 'application/pdf' + | 'application/x-elf' | 'application/x-msdownload' | 'application/x-shockwave-flash' | 'application/rtf' diff --git a/core.js b/core.js index b69d1087..c3685b63 100644 --- a/core.js +++ b/core.js @@ -214,6 +214,13 @@ class FileTypeParser { // -- 4-byte signatures -- + if (this.check([0x7F, 0x45, 0x4C, 0x46])) { + return { + ext: 'elf', + mime: 'application/x-elf', + }; + } + if (this.check([0x47, 0x49, 0x46])) { return { ext: 'gif', diff --git a/fixture/fixture.elf b/fixture/fixture.elf new file mode 100644 index 0000000000000000000000000000000000000000..2eeeb9d4d00cf94be2d2a62558028c8f3d74e841 GIT binary patch literal 142 zcmb<-^>JflWc0{X2+uFdN#SB*U}j)sU|?uyVBs(U(hNITfW+B`*AWT~Obi+ftPCt* zd5{zXPz?w#0y06E6(lCW0G3|@WG
R=ftOdHrfPkYv~a
I5;)rc051O*%K!iX
literal 0
HcmV?d00001
diff --git a/package.json b/package.json
index d68a30c0..7b286dea 100644
--- a/package.json
+++ b/package.json
@@ -51,6 +51,7 @@
"check",
"is",
"exif",
+ "elf",
"exe",
"binary",
"buffer",
diff --git a/readme.md b/readme.md
index 57536359..d6af2e40 100644
--- a/readme.md
+++ b/readme.md
@@ -371,6 +371,7 @@ Returns a `Set