add support for doctype in SVG

This commit is contained in:
Régis Hanol 2017-08-07 10:14:37 +02:00
parent 921ed9a580
commit 2b4b69d80e
3 changed files with 7 additions and 4 deletions

View File

@ -491,7 +491,7 @@ class FastImage
:webp if @stream.peek(12)[8..11] == "WEBP"
when "<s"
:svg
when "<?"
when /<[?!]/
# Peek 10 more chars each time, and if end of file is reached just raise
# unknown. We assume the <svg tag cannot be within 10 chars of the end of
# the file, and is within the first 250 chars.

2
test/fixtures/test4.svg vendored Normal file
View File

@ -0,0 +1,2 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="271px" height="271px" version="1.1" content="&lt;mxfile userAgent=&quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36&quot; version=&quot;7.0.2&quot; editor=&quot;www.draw.io&quot;&gt;&lt;diagram id=&quot;5c6b87c6-fc3f-dea4-eb59-9250f69f05c2&quot; name=&quot;Page-1&quot;&gt;jZJNb4MwDIZ/Te5AVHW7lnXrZScOO6fEkGiBoBBG2K9fIA4fqiqNC87z+ku2Cc0b92FYJz41B0WyhDtC30iWpSd69r+ZTEjSVxpIbSRHtoFC/gLCBOkgOfQHR6u1srI7wlK3LZT2wJgxejy6VVodq3ashgdQlEw90i/JrQj05ZRs/AayFrFymqByZ+V3bfTQYj2S0Wr5gtywmAv9e8G4HneIXgnNjdY2WI3LQc3DjWMLce9P1LVvA639T0AWAn6YGiB2vPRlpzgL32I3m+B8xgvXw31RUv8YhbRQdKycwehvwTNhG4Uy67uwnEo68AUvWAyMBfe04XQdg78v0A1YM3kXDKDxROJpxZ2M256yMzKx29EKGd5Gvebe5uMNHFF8bqtYtN3B0+sf&lt;/diagram&gt;&lt;/mxfile&gt;" style="background-color: rgb(255, 255, 255);"><defs/><g transform="translate(0.5,0.5)"><rect x="0" y="0" width="270" height="270" fill="#ffffff" stroke="#000000" pointer-events="none"/><rect x="2" y="2" width="266" height="266" fill="#ffffff" stroke="#000000" pointer-events="none"/></g></svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -33,7 +33,8 @@ GoodFixtures = {
"test.svg" => [:svg, [200, 300]],
"test_partial_viewport.svg" => [:svg, [860, 400]],
"test2.svg" => [:svg, [366, 271]],
"test3.svg" => [:svg, [255, 48]]
"test3.svg" => [:svg, [255, 48]],
"test4.svg" => [:svg, [271, 271]]
}
BadFixtures = [