summaryrefslogtreecommitdiffstats
path: root/lualib/lua_magic
diff options
context:
space:
mode:
Diffstat (limited to 'lualib/lua_magic')
-rw-r--r--lualib/lua_magic/patterns.lua144
-rw-r--r--lualib/lua_magic/types.lua59
2 files changed, 196 insertions, 7 deletions
diff --git a/lualib/lua_magic/patterns.lua b/lualib/lua_magic/patterns.lua
index 354f8ec61..a52baa790 100644
--- a/lualib/lua_magic/patterns.lua
+++ b/lualib/lua_magic/patterns.lua
@@ -20,14 +20,12 @@ limitations under the License.
--]]
local patterns = {
- {
- -- MSDOS extension to match types table
- ext = 'pdf',
+ pdf = {
-- These are alternatives
matches = {
{
string = [[%PDF-\d]],
- position = 6, -- must be end of the match, as that's how hyperscan works
+ position = 6, -- must be end of the match, as that's how hyperscan works (or use relative_position)
weight = 60,
},
{
@@ -41,6 +39,144 @@ local patterns = {
weight = 60,
},
},
+ },
+ ps = {
+ matches = {
+ {
+ string = [[%!PS-Adobe]],
+ relative_position = 0,
+ weight = 60,
+ },
+ },
+ },
+ -- RTF document
+ rtf = {
+ matches = {
+ {
+ string = [[{\\rtf\d]],
+ position = 6,
+ weight = 60,
+ }
+ }
+ },
+ chm = {
+ matches = {
+ {
+ string = [[ITSF]],
+ relative_position = 0,
+ weight = 60,
+ }
+ }
+ },
+ djvu = {
+ matches = {
+ {
+ string = [[AT&TFORM]],
+ relative_position = 0,
+ weight = 60,
+ },
+ {
+ string = [[DJVM]],
+ relative_position = 0x0c,
+ weight = 60,
+ }
+ }
+ },
+ -- MS Exe file
+ exe = {
+ matches = {
+ {
+ string = [[MZ]],
+ relative_position = 0,
+ weight = 10,
+ },
+ -- PE part
+ {
+ string = [[PE\x{00}\x{00}]],
+ position = {'>=', 0x3c + 4},
+ weight = 40,
+ }
+ }
+ },
+ -- Archives
+ arj = {
+ matches = {
+ {
+ hex = '60EA',
+ relative_position = 0,
+ weight = 60,
+ },
+ }
+ },
+ ace = {
+ matches = {
+ {
+ string = [[\*\*ACE\*\*]],
+ position = 14,
+ weight = 60,
+ },
+ }
+ },
+ cab = {
+ matches = {
+ {
+ string = [[MSCF]],
+ relative_position = 0,
+ weight = 60,
+ },
+ }
+ },
+ -- Images
+ psd = {
+ matches = {
+ {
+ string = [[8BPS]],
+ relative_position = 0,
+ weight = 60,
+ },
+ }
+ },
+ ico = {
+ matches = {
+ {
+ hex = [[00000100]],
+ relative_position = 0,
+ weight = 60,
+ },
+ }
+ },
+ pcx = {
+ matches = {
+ {
+ hex = [[0A050108]],
+ relative_position = 0,
+ weight = 60,
+ },
+ }
+ },
+ pic = {
+ matches = {
+ {
+ hex = [[FF80C9C71A00]],
+ relative_position = 0,
+ weight = 60,
+ },
+ }
+ },
+ -- Other
+ pgp = {
+ matches = {
+ {
+ hex = [[A803504750]],
+ relative_position = 0,
+ weight = 60,
+ },
+ {
+ hex = [[2D424547494E20504750204D4553534147452D]],
+ relative_position = 0,
+ weight = 60,
+ },
+ }
}
}
diff --git a/lualib/lua_magic/types.lua b/lualib/lua_magic/types.lua
index 746c87400..667296715 100644
--- a/lualib/lua_magic/types.lua
+++ b/lualib/lua_magic/types.lua
@@ -22,17 +22,70 @@ limitations under the License.
-- This table is indexed by msdos extension for convenience
local types = {
+ -- exe
+ exe = {
+ ct = 'application/x-ms-application',
+ type = 'executable',
+ },
+ -- text
+ rtf = {
+ ct = "application/rtf",
+ type = 'text',
+ },
pdf = {
ct = 'application/pdf',
type = 'binary',
},
- exe = {
- ct = 'application/x-ms-application',
- type = 'executable',
+ ps = {
+ ct = 'application/postscript',
+ type = 'binary',
+ },
+ chm = {
+ ct = 'application/chm',
+ type = 'binary',
+ },
+ djvu = {
+ ct = 'application/djvu',
+ type = 'binary',
+ },
+ -- archives
+ arj = {
+ ct = 'application/x-compressed',
+ type = 'archive',
+ },
+ cab = {
+ ct = 'application/x-compressed',
+ type = 'archive',
+ },
+ ace = {
+ ct = 'application/x-compressed',
+ type = 'archive',
+ },
+ -- images
+ psd = {
+ ct = 'image/psd',
+ type = 'image',
+ },
+ pcx = {
+ ct = 'image/pcx',
+ type = 'image',
+ },
+ pic = {
+ ct = 'image/pic',
+ type = 'image',
},
tiff = {
ct = 'image/tiff',
type = 'image',
+ },
+ ico = {
+ ct = 'image/ico',
+ type = 'image',
+ },
+ -- other
+ pgp = {
+ ct = 'application/encrypted',
+ type = 'encrypted'
}
}