Improve SVG sniffing

The way this rule works is it check two things:
- The document starts with "<?xml", "<svg", or "<DOCTYPE"
- In the first 512 bytes there is either an SVG or DOCTYPE SVG opening
  tag (both casze insensitive)

This should allow to correctly detect most SVG files, all while not
misdetecting other things (for example xhtml with a nested SVG) too
easily. It's difficult to be completely accurate with just a sniffing
rule.

Change-Id: I66d6e21ff694c4a6349989db2685dffb44ef5767
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2681
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
(cherry picked from commit 0f161e0136)
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2694
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Adrien Destugues 2020-05-11 11:25:08 +02:00 committed by waddlesplash
parent 1c725e51f1
commit 796f97fc62

View File

@ -6,7 +6,7 @@ resource(1, "META:TYPE") "image/svg+xml";
resource(2, "META:S:DESC") #'MSDC' "SVG image";
resource(3, "META:SNIFF_RULE") #'CSTR' array {
"0.60 (\"<?xml\" | \"<svg\") [0:511] ( -i \"<SVG\" | \"<!DOCTYPE SVG\" )"
"0.60 (\"<?xml\" | \"<svg\" | \"<DOCTYPE\") [0:511] ( -i \"<SVG\" | \"<!DOCTYPE SVG\" )"
};
resource(4, "META:PREF_APP") #'MSIG' "application/x-vnd.Haiku-WebPositive";