Skip to content

Commit 8e28563

Browse files
authored
Merge pull request #74 from ursm/fix-html-with-svg
Fix magic detection for HTML with `<svg`
2 parents 275e8c6 + 98b3692 commit 8e28563

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/marcel/tables.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,7 @@ module Marcel
23992399
['image/bmp', [[0, b['BM'], [[26, b["\001\000"], [[28, b["\000\000"]], [28, b["\001\000"]], [28, b["\004\000"]], [28, b["\b\000"]], [28, b["\020\000"]], [28, b["\030\000"]], [28, b[" \000"]]]]]]]],
24002400
['image/vnd.adobe.photoshop', [[0, b["8BPS\000\001"]], [0, b["8BPS\000\002"]]]],
24012401
['image/webp', [[0, b['RIFF'], [[8, b['WEBP']]]]]],
2402+
['text/html', [[0..64, b['<!DOCTYPE HTML']], [0..64, b['<!DOCTYPE html']], [0..64, b['<!doctype HTML']], [0..64, b['<!doctype html']], [0..64, b['<HEAD']], [0..64, b['<head']], [0..64, b['<TITLE']], [0..64, b['<title']], [0..64, b['<HTML']], [0, b['<BODY']], [0, b['<body']], [0, b['<DIV']], [0, b['<div']], [0, b['<TITLE']], [0, b['<title']], [0, b['<h1']], [0, b['<H1']], [0..128, b['<html']]]],
24022403
['image/svg+xml', [[0..4096, b['<svg']]]],
24032404
['video/x-msvideo', [[0, b['RIFF'], [[8, b['AVI ']]]], [8, b['AVI ']]]],
24042405
['video/x-ms-wmv', [[0..8192, b['Windows Media Video']], [0..8192, b['VC-1 Advanced Profile']], [0..8192, b['wmv2']]]],
@@ -2411,7 +2412,7 @@ module Marcel
24112412
['video/x-flv', [[0, b['FLV']]]],
24122413
['audio/mpeg', [[0, b["\377\362"]], [0, b["\377\363"]], [0, b["\377\364"]], [0, b["\377\365"]], [0, b["\377\366"]], [0, b["\377\367"]], [0, b["\377\372"]], [0, b["\377\373"]], [0, b["\377\374"]], [0, b["\377\375"]], [0, b["\377\377"]], [0, b['ID3']]]],
24132414
['application/pdf', [[0, b['%PDF-']], [0, b["\357\273\277%PDF-"]]]],
2414-
['application/msword', [[0..8, b["\320\317\021\340\241\261\032\341"], [[546, b['jbjb']], [546, b['bjbj']]]]]],
2415+
['application/msword', [[2080, b['Microsoft Word 6.0 Document']], [2080, b['Documento Microsoft Word 6']], [2112, b['MSWordDoc']], [0, b["1\276\000\000"]], [0, b['PO^Q`']], [0, b["\3767\000#"]], [0, b["\333\245-\000\000\000"]], [0, b["\224\246."]], [0..8, b["\320\317\021\340\241\261\032\341"], [[1152..4096, b["W\000o\000r\000d\000D\000o\000c\000u\000m\000e\000n\000t"]]]]]],
24152416
['application/vnd.openxmlformats-officedocument.wordprocessingml.document', [[0, b["PK\003\004"], [[30..65536, b['[Content_Types].xml'], [[0..4096, b['word/']]]], [30, b['_rels/.rels'], [[0..4096, b['word/']]]]]]]],
24162417
['application/vnd.ms-powerpoint', [[0..8, b["\320\317\021\340\241\261\032\341"], [[1152..4096, b["P\000o\000w\000e\000r\000P\000o\000i\000n\000t\000 D\000o\000c\000u\000m\000e\000n\000t"]]]]]],
24172418
['application/vnd.openxmlformats-officedocument.presentationml.presentation', [[0, b["PK\003\004"], [[30..65536, b['[Content_Types].xml'], [[0..4096, b['ppt/']]]], [30, b['_rels/.rels'], [[0..4096, b['ppt/']]]]]]]],
@@ -2499,7 +2500,7 @@ module Marcel
24992500
['application/javascript', [[0, b['/* jQuery ']], [0, b['/*! jQuery ']], [0, b['/*!'], [[4..8, b['* jQuery ']]]], [0, b['(function(e,undefined){']], [0, b['!function(window,undefined){']], [0, b['/* Prototype JavaScript ']], [0, b['var Prototype={']], [0, b['function $w(t){']], [0, b['/** @license React']], [0, b['/**'], [[4..8, b['* React ']]]]]],
25002501
['application/mac-binhex40', [[11, b['must be converted with BinHex']]]],
25012502
['application/mathematica', [[0, b['(**']], [0, b['(* ']]]],
2502-
['application/msword', [[2080, b['Microsoft Word 6.0 Document']], [2080, b['Documento Microsoft Word 6']], [2112, b['MSWordDoc']], [0, b["1\276\000\000"]], [0, b['PO^Q`']], [0, b["\3767\000#"]], [0, b["\333\245-\000\000\000"]], [0, b["\224\246."]], [0..8, b["\320\317\021\340\241\261\032\341"], [[1152..4096, b["W\000o\000r\000d\000D\000o\000c\000u\000m\000e\000n\000t"]]]]]],
2503+
['application/msword', [[0..8, b["\320\317\021\340\241\261\032\341"], [[546, b['jbjb']], [546, b['bjbj']]]]]],
25032504
['application/msword2', [[0, b["\233\245"]], [0, b["\333\245"]]]],
25042505
['application/msword5', [[0, b["\3767"]]]],
25052506
['application/octet-stream', [[10, b['# This is a shell archive']], [0, b["\037\036"]], [0, b["\037\037"]], [0, b["\377\037"]], [0, b["\377\037"]], [0, b["\005\313"]]]],
@@ -2738,7 +2739,6 @@ module Marcel
27382739
['audio/amr', [[0, b["#!AMR\n"]], [0, b['#!AMR']]]],
27392740
['image/vnd.zbrush.pcx', [[0, b["\n"], [[1, b["\000"]], [1, b["\002"]], [1, b["\003"]], [1, b["\004"]], [1, b["\005"]]]]]],
27402741
['message/rfc822', [[0..1000, b["\nMessage-ID:"]]]],
2741-
['text/html', [[0..64, b['<!DOCTYPE HTML']], [0..64, b['<!DOCTYPE html']], [0..64, b['<!doctype HTML']], [0..64, b['<!doctype html']], [0..64, b['<HEAD']], [0..64, b['<head']], [0..64, b['<TITLE']], [0..64, b['<title']], [0..64, b['<HTML']], [0, b['<BODY']], [0, b['<body']], [0, b['<DIV']], [0, b['<div']], [0, b['<TITLE']], [0, b['<title']], [0, b['<h1']], [0, b['<H1']], [0..128, b['<html']]]],
27422742
['text/vtt', [[0, b["WEBVTT\r"]], [0, b["WEBVTT\n"]], [0, b['0xfeff'], [[2, b["WEBVTT\r"]]]], [0, b['0xfeff'], [[2, b["WEBVTT\n"]]]], [0, b["WEBVTT FILE\r"]], [0, b["WEBVTT FILE\n"]]]],
27432743
['text/x-matlab', [[0, b["function [a-zA-Z][A-Za-z0-9_]{0,62}\\\\s*="]]]],
27442744
['text/x-matlab', [[0, b["function [a-zA-Z][A-Za-z0-9_]{0,62}[\\\\r\\\\n]"]]]],

script/generate_tables.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ def get_matches(parent)
155155
"image/bmp", # .bmp
156156
"image/vnd.adobe.photoshop", # .psd
157157
"image/webp", # .webp
158+
"text/html", # .html
158159
"image/svg+xml", # .svg
159160

160161
"video/x-msvideo", # .avi
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<svg></svg>
4+
</html>

0 commit comments

Comments
 (0)