Identify svg files that start with white spaces

This commit is contained in:
Fabrizio Monti 2021-02-16 10:26:31 +01:00
parent a440798854
commit fcf871e637
3 changed files with 3 additions and 1 deletions

View File

@ -547,7 +547,7 @@ class FastImage
:webp if @stream.peek(12)[8..11] == "WEBP"
when "<s"
:svg if @stream.peek(4) == "<svg"
when /<[?!]/
when /\s\s|\s<|<[?!]/
# 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.

1
test/fixtures/test5.svg vendored Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -39,6 +39,7 @@ GoodFixtures = {
"test2.svg" => [:svg, [366, 271]],
"test3.svg" => [:svg, [255, 48]],
"test4.svg" => [:svg, [271, 271]],
"test5.svg" => [:svg, [255, 48]],
"orient_6.jpg"=>[:jpeg, [1250,2500]]
}