Index: req-mail
===================================================================
RCS file: /cvsroot/its/sw/wreq/req-mail,v
retrieving revision 1.4
retrieving revision 1.7
diff -u -r1.4 -r1.7
--- req-mail	1999/05/15 10:41:24	1.4
+++ req-mail	1999/05/19 17:02:41	1.7
@@ -51,6 +51,7 @@
 @body=();
 $body='';  # as description field in req
 $date='';
+$mimetype=''; # If this a mime message, place the type here
 $warn=''; # error message. if set, no auto reply will be sent to sender
 # carry along the group name if given as the 1st arg to the alias:
 $group=defined($ARGV[0])?$ARGV[0]:''; 
@@ -59,6 +60,10 @@
 while(<STDIN>) {
 	chop;
 	last if(/^\s*$/);
+	if (/^\s+/) {
+	  my $prevline = pop(@header);
+	  $_ = $prevline . $_;
+	}
 	push(@header, $_);
 }
 
@@ -69,7 +74,11 @@
 }
 
 $header=join "\n",@header;
-$body=join "\n",@body;
+
+if (grep(/^MIME-Version: /, @header)) {
+	my ($typeline) = grep(/^Content-Type: /i, @header);
+	($mimetype) = $typeline =~ m/Content-Type:\s+([^;]+)/i;
+}
 
 ###parse header for email:
 foreach (@header){
@@ -79,6 +88,8 @@
 	###########################################################
 	}elsif(/^Date:\s+(.*\S)/){ # Date: a b
 		$date=$1;
+	}elsif(/^Subject:\s+(.*)$/){ # Subject: line
+		$subject=$1;
 	}
 	###########################################################
 }
@@ -139,6 +150,44 @@
 if($uid =~ /^(root|diag|sys|adm|lp|nobody|MAILER-DAEMON|postmaster|\
 daemon|bin|uucp|powerdown)/i){
 	#$warn.=" Not send auto-reply to uid $uid."; 
+}
+
+# Unpack MIME subjects
+if ( $subject =~ m%=\?([^\?]+)\?Q\?.+\?=% ) {
+  $charset = $1;
+  for $supcharset (@supcharsets) {
+    if ($charset =~ /$supcharset/i) { # ignore case
+      $subject =~ s/=\?[^\?]+\?Q\?(.+)\?=/$1/g;
+      $subject =~ s/_/ /g;
+      $subject =~ s/=([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
+    }
+  }
+  
+}
+
+# XXX Should parse/unpack MIME mail here.  We only handle text/plain for now.
+if ($mimetype && 'text/plain' ne $mimetype) {
+	# send error back to user
+	&sendMail("$error_from", "", "$email", "",
+		  "Error in sending your request",
+	  "Your request with subject\n\n$subject\n\n" .
+	  "was NOT included in bug list!\n\n".
+	  "We only handle MIME type text/plain or non-MIME for the moment\n" .
+	  "Please resend your request like that, or use the web form.\n\n" .
+	  "Thank you\n");
+	exit 0;
+}
+
+# Skip signature
+if ('' eq $mimetype || 'text/plain' eq $mimetype) {
+    $bodylines = 0;
+    foreach (@body) {    
+	last if (/^-- $/ && $dropmailsig);
+	$bodylines++;
+    }
+    $body=join "\n",@body[0..$bodylines-1];
+} else {
+    $body=join "\n",@body;
 }
 
 ###send the request to the web server
Index: req-config
===================================================================
RCS file: /cvsroot/its/sw/wreq/req-config,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- req-config	1999/05/15 11:21:23	1.5
+++ req-config	1999/05/19 17:02:41	1.6
@@ -14,6 +14,14 @@
 #### If $sendmail is '', relay mails thru this host
 $mailhost='mailhost';
 
+#### Set this to '1' to remove signatures (everything from '\n-- \n)
+#### in incoming mail and set to '' if you want to keep the signature
+$dropmailsig = '1';
+
+#### Supported charsets.  Unescape these charsets when MIME encoded in
+#### mail subject
+@supcharsets = ("iso-8859-1", "iso8859-1");
+
 #### The From address for errors in processing email requests
 #### Note: to prevent mail looping, this address doesn't actually exist.
 $error_from="Support Online Error <req-error\@student.uit.no>";
