Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion data/custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,39 @@
<mime-type type="image/svg+xml">
<sub-class-of type="application/xml" />

<magic priority="80">
<!-- That's the easiest variant: matching SVG files that start with <svg immediately -->
<match value="&lt;svg" type="string" offset="0" />
</magic>

<magic priority="75">
<!-- Match SVG files that start with XML declaration followed by <svg -->
<match value="&lt;?xml" type="string" offset="0">
<match value="&lt;svg" type="string" offset="25:512" />
</match>
</magic>

<magic priority="70">
<!-- Match SVG files with DOCTYPE followed by <svg -->
<match value="&lt;!DOCTYPE svg" type="string" offset="0">
<match value="&lt;svg" type="string" offset="25:1024" />
</match>
</magic>

<magic priority="65">
<!-- Match SVG files with comments followed by <svg -->
<match value="&lt;!--" type="string" offset="0">
<match value="&lt;svg" type="string" offset="4:1024" />
</match>
</magic>

<magic priority="60">
<match value="&lt;svg" type="string" offset="0:4096" />
<!-- Match SVG files with whitespace before <svg tag -->
<match value=" &lt;svg" type="string" offset="0" />
<match value="\n&lt;svg" type="string" offset="0" />
<match value="\r&lt;svg" type="string" offset="0" />
<match value="\r\n&lt;svg" type="string" offset="0" />
<match value="\t&lt;svg" type="string" offset="0" />
</magic>
</mime-type>

Expand Down
6 changes: 5 additions & 1 deletion lib/marcel/tables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ module Marcel
['image/vnd.adobe.photoshop', [[0, b["8BPS\000\001"]], [0, b["8BPS\000\002"]]]],
['image/webp', [[0, b['RIFF'], [[8, b['WEBP']]]]]],
['text/html', [[0, b['(?i)<(html|head|body|title|div)[ >]']], [0, b['(?i)<h[123][ >]']]]],
['image/svg+xml', [[0..4096, b['<svg']]]],
['image/svg+xml', [[0, b['<svg']]]],
['video/x-msvideo', [[0, b['RIFF'], [[8, b['AVI ']]]], [8, b['AVI ']]]],
['video/x-ms-wmv', [[0..8192, b['Windows Media Video']], [0..8192, b['VC-1 Advanced Profile']], [0..8192, b['wmv2']]]],
['video/mp4', [[4, b['ftypmp41']], [4, b['ftypmp42']]]],
Expand All @@ -2541,12 +2541,15 @@ module Marcel
['application/x-endnote-refer', [[0..50, b['%A '], [[0..1000, b["\n%D "], [[0..1000, b["\n%T "]]]]]]]],
['application/x-ms-owner', [[0, b["(?s)^([\\\\005-\\\\017])[\\\\000\\\\040-\\\\176]{10}.{43}\\\\1\\000"]]]],
['application/x-tmx', [[0..256, b['<tmx']]]],
['image/svg+xml', [[0, b['<?xml'], [[25..512, b['<svg']]]]]],
['application/mbox', [[0, b['From '], [[32..256, b["\nFrom: "]], [32..256, b["\nDate: "]], [32..256, b["\nSubject: "]], [32..256, b["\nDelivered-To: "]], [32..256, b["\nReceived: by "]], [32..256, b["\nReceived: via "]], [32..256, b["\nReceived: from "]], [32..256, b["\nMime-Version: "]], [32..256, b["\nX-"], [[32..8192, b["\nFrom: "]], [32..8192, b["\nDate: "]], [32..8192, b["\nSubject: "]], [32..8192, b["\nDelivered-To: "]], [32..8192, b["\nReceived: by "]], [32..8192, b["\nReceived: via "]], [32..8192, b["\nReceived: from "]], [32..8192, b["\nMime-Version: "]]]]]]]],
['application/x-bplist', [[0, b["bplist\000\000"]], [0, b["bplist\000\001"]], [0, b["bplist@\000"]], [0, b['bplist00']], [0, b['bplist01']], [0, b['bplist10']], [0, b['bplist15']], [0, b['bplist16']]]],
['application/x-dvd-ifo', [[0, b['DVDVIDEO-VTS']], [0, b['DVDVIDEO-VMG']]]],
['application/x-ebu-stl', [[3, b['STL'], [[8, b['.01']]]]]],
['application/x-ms-nls', [[0, b["(?s)^\\\\015.{51}\\\\014\\\\000\\\\015\\\\000\\\\016"]], [0, b["(?s)^\\\\104\\\\103.\\\\001"]]]],
['image/svg+xml', [[0, b['<!DOCTYPE svg'], [[25..1024, b['<svg']]]]]],
['message/x-emlx', [[2..9, b["\nRelay-Version:"]], [2..9, b["\n#! rnews"]], [2..9, b["\nN#! rnews"]], [2..9, b["\nForward to"]], [2..9, b["\nPipe to"]], [2..9, b["\nReturn-Path:"]], [2..9, b["\nFrom:"]], [2..9, b["\nReceived:"]], [2..9, b["\nMessage-ID:"]], [2..9, b["\nDate:"]]]],
['image/svg+xml', [[0, b['<!--'], [[4..1024, b['<svg']]]]]],
['application/cbor', [[0, b["\331\331\367"]]]],
['application/coreldraw', [[0, b['RIFF'], [[8, b['CDR']], [8, b['cdr']], [8, b['DES']], [8, b['des']]]]]],
['application/illustrator+ps', [[0..8192, b["[\\r\\n]%AI5_FileFormat [1-4][\\r\\n]"]]]],
Expand Down Expand Up @@ -2615,6 +2618,7 @@ module Marcel
['image/heic-sequence', [[4, b['ftyphevc']], [4, b['ftyphevx']]]],
['image/heif', [[4, b['ftypmif1']]]],
['image/heif-sequence', [[4, b['ftypmsf1']]]],
['image/svg+xml', [[0, b[' <svg']], [0, b["\n<svg"]], [0, b["\r<svg"]], [0, b["\r\n<svg"]], [0, b["\t<svg"]]]],
['image/x-canon-cr2', [[0, b["MM\000*"], [[8, b['CR']]]], [0, b["II*\000"], [[8, b['CR']]]], [0, b["MM\000+"], [[8, b['CR']]]]]],
['image/x-canon-cr3', [[4, b['ftypcrx ']]]],
['message/news', [[0, b['Path:']], [0, b['Xref:']]]],
Expand Down
Binary file added test/fixtures/magic/audio/mpeg/audio1.mp3
Binary file not shown.
2 changes: 2 additions & 0 deletions test/fixtures/name/text/csv/svg.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Name,Age,Occupation
Marcel Marceau,94,"<svg></svg>"
2 changes: 2 additions & 0 deletions test/fixtures/name/text/javascript/javascript.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
svg=`<svg xmlns="http://www.w3.org/2000/svg"/>`;

function() {
alert("test")
}