From 39be9db453245cf561148e3f0e17c58dec2ce747 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 21 Sep 2019 13:47:55 +0100 Subject: [PATCH] [Minor] Fix tests and jpeg case --- lualib/lua_magic/heuristics.lua | 8 +-- lualib/lua_magic/types.lua | 4 -- test/functional/cases/350_magic.robot | 2 - test/functional/messages/gargantua.eml | 68 +------------------------- 4 files changed, 5 insertions(+), 77 deletions(-) diff --git a/lualib/lua_magic/heuristics.lua b/lualib/lua_magic/heuristics.lua index d8c134e57..04c89ba69 100644 --- a/lualib/lua_magic/heuristics.lua +++ b/lualib/lua_magic/heuristics.lua @@ -74,9 +74,6 @@ local txt_patterns = { csv = { [[(?:[-a-zA-Z0-9_]+\s*,){2,}(?:[-a-zA-Z0-9_]+[\r\n])]] }, - js = { - [[\s*function\s*\(]], - }, } -- Used to match pattern index and extension @@ -303,7 +300,10 @@ exports.mime_part_heuristic = function(part, log_obj) if part:is_image() then local img = part:get_image() - return img:get_type():lower(),60 + local img_type = img:get_type():lower() + + if img_type == 'jpeg' then img_type = 'jpg' end + return img_type,60 end if part:is_archive() then diff --git a/lualib/lua_magic/types.lua b/lualib/lua_magic/types.lua index 93bfa6641..32c7cd131 100644 --- a/lualib/lua_magic/types.lua +++ b/lualib/lua_magic/types.lua @@ -258,10 +258,6 @@ local types = { type = 'message', ct = 'message/rfc822', }, - js = { - type = 'application', - ct = 'application/javascript', - }, } return types \ No newline at end of file diff --git a/test/functional/cases/350_magic.robot b/test/functional/cases/350_magic.robot index 02c4e89a2..5ef0dc172 100644 --- a/test/functional/cases/350_magic.robot +++ b/test/functional/cases/350_magic.robot @@ -63,8 +63,6 @@ Magic detections bundle 1 Should Contain ${result.stdout} MAGIC_SYM_TXT_48 Should Contain ${result.stdout} MAGIC_SYM_HTML_49 Should Contain ${result.stdout} MAGIC_SYM_CSV_50 - Should Contain ${result.stdout} MAGIC_SYM_EML_52 - Should Contain ${result.stdout} MAGIC_SYM_JS_51 Should Contain ${result.stdout} MAGIC_SYM_JPG_45 diff --git a/test/functional/messages/gargantua.eml b/test/functional/messages/gargantua.eml index bc13b8cf6..bc7883490 100644 --- a/test/functional/messages/gargantua.eml +++ b/test/functional/messages/gargantua.eml @@ -23256,73 +23256,7 @@ Content-Type: application/octet-stream Content-Transfer-Encoding: base64 X-Real-Type: csv -Ozs7Ozs7DQo7YXNzYWQ7Ozs7Ow0KO3NhbGFkczs7Ozs7DQo7Ozs7OzsNCjs7Ozs7 -Ow0KOzs7Ozs7DQo7Ozs7OzsNCjs7Ozs7Ow0KOzthc2Rhc2Q7Ozs7DQo= - ---XXX -Content-Type: application/octet-stream -Content-Transfer-Encoding: base64 -X-Real-Type: js - -LyogZ2xvYmFsIGQzOnRydWUsIHJlcXVpcmU6ZmFsc2UsIHJlcXVpcmVqczpmYWxz -ZSAqLyAvLyBlc2xpbnQtZGlzYWJsZS1saW5lIG5vLXVudXNlZC12YXJzCgpyZXF1 -aXJlanMuY29uZmlnKHsKICAgIGJhc2VVcmw6ICJqcy9saWIiLAogICAgcGF0aHM6 -IHsKICAgICAgICBhcHA6ICIuLi9hcHAiLAogICAgICAgIGpxdWVyeTogImpxdWVy -eS0zLjQuMS5taW4iLAogICAgICAgIHZpc2liaWxpdHk6ICJ2aXNpYmlsaXR5Lm1p -biIsCiAgICAgICAgaHVtYW5pemU6ICJodW1hbml6ZS5taW4iLAogICAgICAgIGJv -b3RzdHJhcDogImJvb3RzdHJhcC5taW4iLAogICAgICAgIGQzOiAiZDMubWluIiwK -ICAgICAgICBkM2V2b2x1dGlvbjogImQzZXZvbHV0aW9uLm1pbiIsCiAgICAgICAg -ZDNwaWU6ICJkM3BpZS5taW4iLAogICAgICAgIGZvb3RhYmxlOiAiZm9vdGFibGUu -bWluIiwKICAgICAgICBucHJvZ3Jlc3M6ICJucHJvZ3Jlc3MubWluIiwKICAgICAg -ICBzdGlja3l0YWJzOiAianF1ZXJ5LnN0aWNreXRhYnMubWluIgogICAgfSwKICAg -IHNoa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Ju -b3RpZmljYXRpb24tYXJlYSIpWzBdLmlubmVySFRNTCA9CiAgICAgICAgIjxkaXYg -Y2xhc3M9XCJhbGVydCBhbGVydC1lcnJvclwiPiIgKwogICAgICAgICAgICAiPHN0 -cm9uZz5Nb2R1bGUgbG9hZGluZyBlcnJvcjogIiArIGUucmVxdWlyZVR5cGUgKyAi -LCBtb2R1bGU6ICIgKyBlLnJlcXVpcmVNb2R1bGVzICsgIjwvc3Ryb25nPiIgKwog -ICAgICAgICAgICAiPGJ1dHRvbiB0eXBlPVwiYnV0dG9uXCIgY2xhc3M9XCJidG4g -YnRuLWluZm8gYnRuLXhzIHB1bGwtcmlnaHRcIiAiICsKICAgICAgICAgICAgICAg -ICJvbkNsaWNrPVwid2luZG93LmxvY2F0aW9uLnJlbG9hZCgpOyB0aGlzLnBhcmVu -dE5vZGUucGFyZW50Tm9kZS5yZW1vdmVDaGlsZCh0aGlzLnBhcmVudE5vZGUpO1wi -ICIgKwogICAgICAgICAgICAgICAgInRpdGxlPVwiUmVsb2FkIGN1cnJlbnQgcGFn -ZVwiPiIgKwogICAgICAgICAgICAgICAgIjxpIGNsYXNzPVwiZ2x5cGhpY29uIGds -eXBoaWNvbi1yZXBlYXRcIj48L2k+IFJlbG9hZCIgKwogICAgICAgICAgICAiPC9i -dXR0b24+IiArCiAgICAgICAgIjwvZGl2PiI7CiAgICB0aHJvdyBlOwp9OwoKLy8g -TG9hZCBtYWluIFVJCnJlcXVpcmUoWyJhcHAvcnNwYW1kIl0sCiAgICBmdW5jdGlv -biAocnNwYW1kKSB7CiAgICAgICAgInVzZSBzdHJpY3QiOwogICAgICAgIHJzcGFt -ZC5zZXR1cCgpOwogICAgICAgIHJzcGFtZC5jb25uZWN0KCk7CiAgICB9Cik7Cg== - ---XXX -Content-Type: message/rfc822 -Content-Transfer-Encoding: base64 -X-Real-Type: eml - -UmVjZWl2ZWQ6ICoNCkZyb206IDwqPg0KVG86ICIqIiA8Kj4NClJlcGx5LVRvOiA8 -Kj4NCkRhdGU6IFRodSwgMTkgU2VwIDIwMTkgMjE6MzM6NDQgKzAzMDANCkNvbnRl -bnQtVHJhbnNmZXItRW5jb2Rpbmc6IDdiaXQNCkNvbnRlbnQtVHlwZTogbXVsdGlw -YXJ0L21peGVkOyBib3VuZGFyeT0iXy0tLS0tLS0tLS09XzE1Njg5MTgwMjQ5MzY5 -MjgiDQpNZXNzYWdlLUlkOiA8Kj4NCk1JTUUtVmVyc2lvbjogMS4wDQoNClRoaXMg -aXMgYSBtdWx0aS1wYXJ0IG1lc3NhZ2UgaW4gTUlNRSBmb3JtYXQuDQoNCi0tXy0t -LS0tLS0tLS09XzE1Njg5MTgwMjQ5MzY5MjgNCkNvbnRlbnQtVHlwZTogbXVsdGlw -YXJ0L2FsdGVybmF0aXZlOyBib3VuZGFyeT0iXy0tLS0tLS0tLS09XzE1Njg5MTgw -MjQ5MzY5MjkiDQoNClRoaXMgaXMgYSBtdWx0aS1wYXJ0IG1lc3NhZ2UgaW4gTUlN -RSBmb3JtYXQuDQoNCg== +dGVzdCwxMjUsNzc3LDc3NwoxLDIsMyw0Cg== --XXX-- \ No newline at end of file -- 2.39.5