marcel
marcel copied to clipboard
Does not detect html if the document contains svg.
Issue
If html file contains svg tag Marcel will detect "image/svg+xml" type. This causes some problems with the browser, it says: "This page contains the following errors:"
Investigation
I use Marcel::MimeType.for and if I give pathname or IO it will call this,
then this (magic_match(io, method)) with :find.
In the end, we iterate by MAGIC and find first matched type.
Conclusion
When I wrote this issue, I found a fix, but the latest version does not have it. When are you planning to release the next release?
Hi there. I'm facing the same issue.
Here is a reproduction code:
io = StringIO.new(<<~HTML)
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Test Page</title>
</head>
<body>
<p>Text Content</p>
<svg width="1" height="1" viewBox="0 0 1 1" xmlns="http://www.w3.org/2000/svg">
<path fill="#AE5D5D" fill-rule="nonzero" d="M0 0h1v1H0z"/>
</svg>
</body>
</html>
HTML
Marcel::Magic.by_magic(io)
#=> #<Marcel::Magic:0x00000001159b9798 @type="image/svg+xml", @mediatype="image", @subtype="svg+xml">
Thanks ❤️
It appears to be fixed in 1.0.3 by #74