chiark / gitweb /
bodge decodeBase64 testing
authorOwen Dunn <owend@chiark.greenend.org.uk>
Thu, 9 Oct 2014 12:34:44 +0000 (13:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 9 Oct 2014 12:35:09 +0000 (13:35 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
stump/bin/decodeBase64

index 61a025b3b19924a536494c1099039a0aca7dd5b1..3eff5b240115833098acfe984d2d80cd19e5c8f9 100755 (executable)
@@ -4,6 +4,7 @@ $isEncoded = 0;
 $FullHeaders = "";
 $DecodedHeaders = "";
 $switch = "";
+$inctype = 0;
 
 while(<>) {
   chop;
@@ -12,6 +13,12 @@ while(<>) {
 
   $FullHeaders .= "$_\n";
 
+  if ( /^\s+/ && $inctype ) {
+      next;
+  }
+
+  $inctype=0;
+
   if( /^Content-Transfer-Encoding: BASE64/i ) {
 
     $isEncoded = 1;
@@ -22,6 +29,9 @@ while(<>) {
     $isEncoded = 1;
     $switch = "-q"; # quoted-printable
 
+  } elsif( /^Content-Type: /i ) {
+    $inctype = 1;
+
   } elsif( ! /^Mime-Version: /i && ! /Content-Type: /i ) {
     $DecodedHeaders .= "$_\n";
   }