From 17626df948e1d384072e6a2f8eab4f7fc6a18d0a Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 10 May 2020 17:25:39 +0200 Subject: [PATCH] Icon-O-Matic: use the MIME sniffer to recognize SVG files Our sniffing rule is not perfect, but it is already a lot better than what was done here. Partially fixes #14437 (the icons also fails parsing for other reasons, but with an error message, at least) Change-Id: I25475b419b5fbe863c71f553a336757d7950bf48 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2662 Reviewed-by: waddlesplash --- .../import_export/svg/SVGImporter.cpp | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/apps/icon-o-matic/import_export/svg/SVGImporter.cpp b/src/apps/icon-o-matic/import_export/svg/SVGImporter.cpp index 534b36c4b3..8b3f176d39 100644 --- a/src/apps/icon-o-matic/import_export/svg/SVGImporter.cpp +++ b/src/apps/icon-o-matic/import_export/svg/SVGImporter.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "DocumentBuilder.h" @@ -51,21 +52,11 @@ SVGImporter::Import(Icon* icon, const entry_ref* ref) if (ret < B_OK) return ret; - // peek into file to see if this could be an SVG file at all - BFile file(path.Path(), B_READ_ONLY); - ret = file.InitCheck(); - if (ret < B_OK) - return ret; - - ssize_t size = 5; - char buffer[size + 1]; - if (file.Read(buffer, size) != size) - return B_ERROR; - - // 0 terminate - buffer[size] = 0; - if (strcasecmp(buffer, "