Skip to content
Closed
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
32 changes: 31 additions & 1 deletion data/custom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@
<sub-class-of type="application/xml" />

<magic priority="60">
<match value="&lt;svg" type="string" offset="0:4096" />
<!-- Easiest path: SVG files that start directly with <svg tag -->
<match value="&lt;svg" type="string" offset="0">
<match value="http://www.w3.org/2000/svg" type="string" offset="5:256" />
</match>
</magic>

<magic priority="60">
<!-- Match SVG files that start with XML declaration, comments, or DOCTYPE -->
<match value="&lt;?xml" type="string" offset="0">
<match value="&lt;svg" type="string" offset="0:1024">
<match value="http://www.w3.org/2000/svg" type="string" offset="5:1280" />
</match>
</match>
</magic>

<magic priority="60">
<!-- Match SVG files that start with comments -->
<match value="&lt;!--" type="string" offset="0">
<match value="&lt;svg" type="string" offset="0:1024">
<match value="http://www.w3.org/2000/svg" type="string" offset="5:1280" />
</match>
</match>
</magic>

<magic priority="60">
<!-- Match SVG files that start with DOCTYPE -->
<match value="&lt;!DOCTYPE" type="string" offset="0">
<match value="&lt;svg" type="string" offset="0:1024">
<match value="http://www.w3.org/2000/svg" type="string" offset="5:1280" />
</match>
</match>
</magic>
</mime-type>

Expand Down
5 changes: 4 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'], [[5..256, b['http://www.w3.org/2000/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 Down Expand Up @@ -2615,6 +2615,9 @@ 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['<?xml'], [[0..1024, b['<svg'], [[5..1280, b['http://www.w3.org/2000/svg']]]]]]]],
['image/svg+xml', [[0, b['<!--'], [[0..1024, b['<svg'], [[5..1280, b['http://www.w3.org/2000/svg']]]]]]]],
['image/svg+xml', [[0, b['<!DOCTYPE'], [[0..1024, b['<svg'], [[5..1280, b['http://www.w3.org/2000/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>"