summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Dard <>2013-03-02 18:25:06 -0600
committerDarrell Anderson <humanreadable@yahoo.com>2013-03-02 18:25:06 -0600
commitb61f0c4777f5257179a02e118fa7965917f359fe (patch)
tree34d544cd544b876b5afb3c0f83934107624612b4
parentb2f408002ea3d19c1e51664fe0511fc9a8119bec (diff)
downloadtdelibs-b61f0c47.tar.gz
tdelibs-b61f0c47.zip
Partial fix for incorrect mimetype detection.
This partially resolves bug report 656.
-rw-r--r--tdeio/tdeio/kmimemagic.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/tdeio/tdeio/kmimemagic.cpp b/tdeio/tdeio/kmimemagic.cpp
index 4d75d8d58..597710e13 100644
--- a/tdeio/tdeio/kmimemagic.cpp
+++ b/tdeio/tdeio/kmimemagic.cpp
@@ -1988,13 +1988,15 @@ static int ascmagic(struct config_rec* conf, unsigned char *buf, int nbytes)
return 1;
}
-/* Maximal length of a line we consider "reasonable". */
-#define TEXT_MAXLINELEN 300
-// This code is taken from the "file" command, where it is licensed
-// in the "beer-ware license" :-)
-// Original author: <joerg@FreeBSD.ORG>
-// Simplified by David Faure to avoid the static array char[256].
+/* This code is taken from the "file" command, where it is licensed
+ * in the "beer-ware license" :-)
+ * Original author: <joerg@FreeBSD.ORG>
+ * Simplified by David Faure to avoid the static array char[256].
+ * Drastically simplified by Laurent Dard for the Trinity Desktop Environment
+ * Configuration files with big lines are still text files:
+ * line length checking is now avoided here.
+ */
static int textmagic(struct config_rec* conf, unsigned char * buf, int nbytes)
{
int i;
@@ -2002,28 +2004,11 @@ static int textmagic(struct config_rec* conf, unsigned char * buf, int nbytes)
nbytes--;
- /* First, look whether there are "unreasonable" characters. */
+ /* Look whether there are "unreasonable" characters. */
for (i = 0, cp = buf; i < nbytes; i++, cp++)
if ((*cp < 8) || (*cp>13 && *cp<32 && *cp!=27 ) || (*cp==0x7F))
return 0;
- /* Now, look whether the file consists of lines of
- * "reasonable" length. */
-
- for (i = 0; i < nbytes;) {
- cp = (unsigned char *) memchr(buf, '\n', nbytes - i);
- if (cp == NULL) {
- /* Don't fail if we hit the end of buffer. */
- if (i + TEXT_MAXLINELEN >= nbytes)
- break;
- else
- return 0;
- }
- if (cp - buf > TEXT_MAXLINELEN)
- return 0;
- i += (cp - buf + 1);
- buf = cp + 1;
- }
conf->resultBuf = MIME_TEXT_PLAIN;
return 1;
}