From fb3a94578c8420c9dbdcc775a55d2d36c63cbdf2 Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 21 Mar 2006 11:04:39 +0000 Subject: [PATCH] sanity check on file -i return --- src/index/mimetype.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/index/mimetype.cpp b/src/index/mimetype.cpp index 01813fa5..5e179c79 100644 --- a/src/index/mimetype.cpp +++ b/src/index/mimetype.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.16 2006-01-23 13:32:28 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: mimetype.cpp,v 1.17 2006-03-21 11:04:39 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -85,14 +85,16 @@ static string mimetypefromdata(const string &fn, bool usfc) // Split it, and take second field list res; stringToStrings(result, res); - if (res.size() <= 1) + if (res.size() <= 1) return ""; list::iterator it = res.begin(); - it++; - mime = *it; + mime = *++it; // Remove possible punctuation at the end if (mime.length() > 0 && !isalpha(mime[mime.length() - 1])) mime.erase(mime.length() -1); + // File -i will sometimes return strange stuff (ie: "very small file") + if(mime.find("/") == string::npos) + mime = ""; } #endif