From 426a4feb38645fc31e3530a51eef0f683f6e61ad Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 5 Aug 2018 22:20:27 +0200 Subject: fix #5404 --- src/plugins/ole2_extractor.c | 45 +++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/plugins/ole2_extractor.c b/src/plugins/ole2_extractor.c index e8e210e..878b8a4 100644 --- a/src/plugins/ole2_extractor.c +++ b/src/plugins/ole2_extractor.c @@ -222,24 +222,35 @@ process_metadata (gpointer key, } if (NULL == contents) return; - if (0 == strcmp (type, "meta:generator")) + if (0 == strcmp (type, + "meta:generator")) { const char *mimetype = "application/vnd.ms-files"; - if ( (0 == strncmp (value, "Microsoft Word", 14)) || - (0 == strncmp (value, "Microsoft Office Word", 21))) - mimetype = "application/msword"; - else if ( (0 == strncmp(value, "Microsoft Excel", 15)) || - (0 == strncmp(value, "Microsoft Office Excel", 22)) ) - mimetype = "application/vnd.ms-excel"; - else if ( (0 == strncmp(value, "Microsoft PowerPoint", 20)) || - (0 == strncmp(value, "Microsoft Office PowerPoint", 27)) ) - mimetype = "application/vnd.ms-powerpoint"; - else if (0 == strncmp(value, "Microsoft Project", 17)) - mimetype = "application/vnd.ms-project"; - else if (0 == strncmp(value, "Microsoft Visio", 15)) - mimetype = "application/vnd.visio"; - else if (0 == strncmp(value, "Microsoft Office", 16)) - mimetype = "application/vnd.ms-office"; + struct { + const char *v; + const char *m; + } mm[] = { + { "Microsoft Word", "application/msword" }, + { "Microsoft Office Word", "application/msword" }, + { "Microsoft Excel", "application/vnd.ms-excel" }, + { "Microsoft Office Excel", "application/vnd.ms-excel" }, + { "Microsoft PowerPoint", "application/vnd.ms-powerpoint" }, + { "Microsoft Office PowerPoint", "application/vnd.ms-powerpoint"}, + { "Microsoft Project", "application/vnd.ms-project" }, + { "Microsoft Visio", "application/vnd.visio" }, + { "Microsoft Office", "application/vnd.ms-office" }, + { NULL, NULL } + }; + int i; + + for (i=0;NULL != mm[i].v; i++) + if (0 == strncmp (value, + mm[i].v, + strlen (mm[i].v) + 1)) + { + mimetype = mm[i].m; + break; + } if (0 != add_metadata (pc->proc, pc->proc_cls, mimetype, @@ -336,7 +347,7 @@ process_star_office (GsfInput *src, (buf[1] != 0x0) || (0 != strncmp (&buf[2], "SfxDocumentInfo", - strlen ("SfxDocumentInfo"))) || + strlen ("SfxDocumentInfo") + 1)) || (buf[0x11] != 0x0B) || (buf[0x13] != 0x00) || /* pw protected! */ (buf[0x12] != 0x00) ) -- cgit v1.2.3