cope with uppercase mime encodings
[org.ibex.mail.git] / src / org / ibex / mail / MIME.java
index c8dce2a..0da4d53 100644 (file)
@@ -20,21 +20,21 @@ import java.io.*;
 public class MIME {
 
     public static class Part extends JSReflection implements Fountain {
-        public  final  Headers      headers;
-        public  final  ContentType  contentType;
-        private final  String       encoding;
+        public  final Headers      headers;
+        public  final ContentType  contentType;
+        private final String       encoding;
 
         private final Fountain     all;
         private final Fountain     body;
 
-        public Stream getStream() { return all.getStream(); }
-        public int getNumLines()  { return all.getNumLines(); }
-        public int getLength()    { return all.getLength(); }
+        public Stream getStream()   { return all.getStream(); }
+        public int getNumLines()    { return all.getNumLines(); }
+        public long getLength()     { return all.getLength(); }
         public Fountain getBody()   { return body; }
 
         private class BodyFountain implements Fountain {
             public int getNumLines()  { return Stream.countLines(getStream()); }
-            public int getLength()    { return Part.this.getLength() - headers.getLength() - 2; }
+            public long getLength()   { return Part.this.getLength() - headers.getLength() - 2 /*FIXME: correct?*/; }
             public Stream getStream() {
                 return /*
                          "quoted-printable".equals(encoding) ? Encode.QuotedPrintable.decode(body.toString(),false) :
@@ -48,9 +48,10 @@ public class MIME {
             this.headers     = new Headers.Original(all.getStream());
             String ctype     = headers.get("content-type");
             this.encoding    = headers.get("content-transfer-encoding");
-            if (!(encoding == null || encoding.equals("7bit") || encoding.equals("8bit") || encoding.equals("binary") ||
-                  encoding.equals("quoted-printable") || encoding.equals("base64"))) {
-                // FIXME: "7BIT" is popular
+            String enc = this.encoding;
+            if (enc!=null) enc = enc.toLowerCase();
+            if (!(enc == null || enc.equals("7bit") || enc.equals("8bit") || enc.equals("binary") ||
+                  enc.equals("quoted-printable") || enc.equals("base64"))) {
                 Log.warn(MIME.class, "unknown TransferEncoding \"" + encoding + "\"");
                 ctype = "application/octet-stream";
             }