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 <[email protected]>
This commit is contained in:
Adrien Destugues
2020-05-13 18:22:04 +00:00
committed by Adrien Destugues
parent 11d6332fe8
commit 0f161e0136
+1 -1
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";