Browse code

Tidy up

git-svn: trunk@1012

Nigel Horne authored on 2004/10/17 05:53:28
Showing 2 changed files
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: mbox.c,v $
20
+ * Revision 1.157  2004/10/16 20:53:28  nigelhorne
21
+ * Tidy up
22
+ *
20 23
  * Revision 1.156  2004/10/16 19:09:39  nigelhorne
21 24
  * Handle BeMail (BeOS) files
22 25
  *
... ...
@@ -456,7 +459,7 @@
456 456
  * Compilable under SCO; removed duplicate code with message.c
457 457
  *
458 458
  */
459
-static	char	const	rcsid[] = "$Id: mbox.c,v 1.156 2004/10/16 19:09:39 nigelhorne Exp $";
459
+static	char	const	rcsid[] = "$Id: mbox.c,v 1.157 2004/10/16 20:53:28 nigelhorne Exp $";
460 460
 
461 461
 #if HAVE_CONFIG_H
462 462
 #include "clamav-config.h"
... ...
@@ -927,6 +930,7 @@ static message *
927 927
 parseEmailHeaders(const message *m, const table_t *rfc821)
928 928
 {
929 929
 	bool inHeader = TRUE;
930
+	bool contMarker = FALSE;
930 931
 	const text *t;
931 932
 	message *ret;
932 933
 	bool anyHeadersFound = FALSE;
... ...
@@ -956,7 +960,7 @@ parseEmailHeaders(const message *m, const table_t *rfc821)
956 956
 				 */
957 957
 				cli_dbgmsg("End of header information\n");
958 958
 				inHeader = FALSE;
959
-			} else if(((buffer[0] == '\t') || (buffer[0] == ' ')) &&
959
+			} else if(((buffer[0] == '\t') || (buffer[0] == ' ') || contMarker) &&
960 960
 				  (!Xheader)) {
961 961
 				/*
962 962
 				 * Section B.2 of RFC822 says TAB or SPACE means
... ...
@@ -970,6 +974,7 @@ parseEmailHeaders(const message *m, const table_t *rfc821)
970 970
 #ifdef CL_THREAD_SAFE
971 971
 				char *strptr;
972 972
 #endif
973
+				contMarker = continuationMarker(buffer);
973 974
 				switch(commandNumber) {
974 975
 					case CONTENT_TRANSFER_ENCODING:
975 976
 					case CONTENT_DISPOSITION:
... ...
@@ -1013,6 +1018,7 @@ parseEmailHeaders(const message *m, const table_t *rfc821)
1013 1013
 #endif
1014 1014
 			} else {
1015 1015
 				Xheader = (bool)(buffer[0] == 'X');
1016
+				contMarker = continuationMarker(buffer);
1016 1017
 				if((parseEmailHeader(ret, buffer, rfc821) >= 0) ||
1017 1018
 				   (strncasecmp(buffer, "From ", 5) == 0)) {
1018 1019
 				   	char cmd[LINE_LENGTH + 1];
... ...
@@ -17,6 +17,9 @@
17 17
  *
18 18
  * Change History:
19 19
  * $Log: message.c,v $
20
+ * Revision 1.102  2004/10/16 20:53:28  nigelhorne
21
+ * Tidy up
22
+ *
20 23
  * Revision 1.101  2004/10/16 13:53:52  nigelhorne
21 24
  * Handle '8 bit' and plain/text
22 25
  *
... ...
@@ -300,7 +303,7 @@
300 300
  * uuencodebegin() no longer static
301 301
  *
302 302
  */
303
-static	char	const	rcsid[] = "$Id: message.c,v 1.101 2004/10/16 13:53:52 nigelhorne Exp $";
303
+static	char	const	rcsid[] = "$Id: message.c,v 1.102 2004/10/16 20:53:28 nigelhorne Exp $";
304 304
 
305 305
 #if HAVE_CONFIG_H
306 306
 #include "clamav-config.h"
... ...
@@ -534,20 +537,26 @@ messageSetMimeType(message *mess, const char *type)
534 534
 	} else if(mess->mimeType == NOMIME) {
535 535
 		if(strncasecmp(type, "x-", 2) == 0)
536 536
 			mess->mimeType = MEXTENSION;
537
-		else if(strcasecmp(type, "plain") != 0) {
537
+		else {
538 538
 			/*
539 539
 			 * Based on a suggestion by James Stevens
540 540
 			 *	<James@kyzo.com>
541 541
 			 * Force scanning of strange messages
542
-			 *
543
-			 * Don't handle broken e-mail probably sending
544
-			 *	Content-Type: plain/text
545
-			 * instead of
546
-			 *	Content-Type: text/plain
547
-			 * as an attachment
548 542
 			 */
549
-			cli_warnmsg("Unknown MIME type: `%s' - set to Application\n", type);
550
-			mess->mimeType = APPLICATION;
543
+			if(strcasecmp(type, "plain") == 0) {
544
+				cli_dbgmsg("Incorrect MIME type: `plain', set to Text\n", type);
545
+				mess->mimeType = TEXT;
546
+			} else {
547
+				/*
548
+				 * Don't handle broken e-mail probably sending
549
+				 *	Content-Type: plain/text
550
+				 * instead of
551
+				 *	Content-Type: text/plain
552
+				 * as an attachment
553
+				 */
554
+				cli_warnmsg("Unknown MIME type: `%s', set to Application - report to bugs@clamav.net\n", type);
555
+				mess->mimeType = APPLICATION;
556
+			}
551 557
 		}
552 558
 		return 1;
553 559
 	}
... ...
@@ -772,7 +781,7 @@ messageAddArguments(message *m, const char *s)
772 772
 
773 773
 			if((string == NULL) || (strlen(key) == 0)) {
774 774
 				if(usefulArg(key))
775
-					cli_warnmsg("Can't parse header (1) \"%s\"\n", s);
775
+					cli_warnmsg("Can't parse header (1) \"%s\" - report to bugs@clamav.net\n", s);
776 776
 				free((char *)key);
777 777
 				return;
778 778
 			}
... ...
@@ -931,12 +940,10 @@ messageSetEncoding(message *m, const char *enctype)
931 931
 	while((*enctype == '\t') || (*enctype == ' '))
932 932
 		enctype++;
933 933
 
934
-	/*
935
-	 * broken:
936
-	 *	Content-Transfer-Encoding: 8 bit
937
-	 */
938
-	if(strcasecmp(enctype, "8 bit") == 0)
934
+	if(strcasecmp(enctype, "8 bit") == 0) {
935
+		cli_dbgmsg("Broken content-transfer-encoding: '8 bit' changed to '8bit'\n");
939 936
 		enctype = "8bit";
937
+	}
940 938
 
941 939
 	/*
942 940
 	 * Iterate through