Skip to content

Commit

Permalink
fix: detect svgs with title as image/svg+xml intead of text/html
Browse files Browse the repository at this point in the history
This issue is introduced after merging #74 and released at 1.0.3.
The title element provides an accessible, short-text description
of the SVG and so cannot be used to determine whether an element
is text/html.
  • Loading branch information
sjoulbak committed Mar 4, 2024
1 parent 1d63b4a commit adb0897
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/marcel/tables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2399,7 +2399,7 @@ module Marcel
['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"]]]]]]]],
['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..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']]]],
['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['<HTML']], [0, b['<BODY']], [0, b['<body']], [0, b['<DIV']], [0, b['<div']], [0, b['<h1']], [0, b['<H1']], [0..128, b['<html']]]],
['image/svg+xml', [[0..4096, 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']]]],
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/magic/image/svg+xml/svg_with_title.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit adb0897

Please sign in to comment.