summary refs log tree commit diff
diff options
context:
space:
mode:
authorDuncaen <mail@duncano.de>2017-02-16 16:32:51 +0100
committerDuncaen <mail@duncano.de>2017-02-23 20:35:14 +0100
commit10ed969f06ed906bd5429f2b520f93b293a3ae8e (patch)
treeb95cb727b2adb27ec2bc8fb52fe3adc8b995ebbe
parent11e62a17c55c2199a3925c4ea19e9a96c383b7c8 (diff)
downloadmblaze-10ed969f06ed906bd5429f2b520f93b293a3ae8e.tar.gz
mblaze-10ed969f06ed906bd5429f2b520f93b293a3ae8e.tar.xz
mblaze-10ed969f06ed906bd5429f2b520f93b293a3ae8e.zip
magrep: match body line by line if -p is specified without -c, -v and -o
-rw-r--r--magrep.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/magrep.c b/magrep.c
index cd7784a..e6e53cc 100644
--- a/magrep.c
+++ b/magrep.c
@@ -84,9 +84,19 @@ match_part(int depth, struct message *msg, char *body, size_t bodylen)
 		    strcasecmp(charset, "utf-8") == 0 ||
 		    strcasecmp(charset, "utf8") == 0 ||
 		    strcasecmp(charset, "us-ascii") == 0) {
-			(void) bodylen;	 /* XXX */
-			if (match(curfile, "/", body))
+			if (pflag && !cflag && !oflag && !vflag) {
+				char *s, *p;
+				for (p = s = body; p < body+bodylen+1; p++) {
+					if (*p == '\r' || *p == '\n') {
+						*p = 0;
+						if (p-s > 1 && match(curfile, "/", s))
+							r = MIME_STOP;
+						s = p+1;
+					}
+				}
+			} else if (match(curfile, "/", body)) {
 				r = MIME_STOP;
+			}
 		} else {
 			/* XXX decode here */
 		}