Closed rven closed 2 years ago
When a svg needs to be parsed with the from_buffer method, it returns an incorrect mimetype when the <?xml version='1.0' encoding='UTF-8' ?> tag is included on top of the xml declaration
with latest version 0.4.27 installed.
https://bugs.astron.com/view.php?id=344#c3746
import magic a = b"<svg height='180' width='180' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='[http://www.w3.org/1999/xlink'><rect](http://www.w3.org/1999/xlink'%3E%3Crect) fill='hsl(349, 60%, 45%)' height='180' width='180'/><text fill='#ffffff' font-size='96' text-anchor='middle' x='90' y='125' font-family='sans-serif'>M</text></svg>" magic.from_buffer(a, mime=True)
=> 'image/svg+xml'
import magic a = b"<?xml version='1.0' encoding='UTF-8' ?><svg height='180' width='180' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='[http://www.w3.org/1999/xlink'><rect](http://www.w3.org/1999/xlink'%3E%3Crect) fill='hsl(349, 60%, 45%)' height='180' width='180'/><text fill='#ffffff' font-size='96' text-anchor='middle' x='90' y='125' font-family='sans-serif'>M</text></svg>" magic.from_buffer(a, mime=True)
=> 'text/xml'
This is a bug in libmagic rather than python-magic, looks like from the bugreport that they've fixed it.
When a svg needs to be parsed with the from_buffer method, it returns an incorrect mimetype when the <?xml version='1.0' encoding='UTF-8' ?> tag is included on top of the xml declaration
with latest version 0.4.27 installed.
https://bugs.astron.com/view.php?id=344#c3746
=> 'image/svg+xml'
=> 'text/xml'