Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not detect html if the document contains svg. #75

Open
AlexanderShvaykin opened this issue Aug 21, 2022 · 2 comments
Open

Does not detect html if the document contains svg. #75

AlexanderShvaykin opened this issue Aug 21, 2022 · 2 comments

Comments

@AlexanderShvaykin
Copy link

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?

@simonc
Copy link

simonc commented Feb 18, 2024

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 ❤️

@genezys
Copy link

genezys commented Jul 18, 2024

It appears to be fixed in 1.0.3 by #74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants