Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2c518620 authored by Daniel Applebaum's avatar Daniel Applebaum
Browse files

Issue 190

Handle uppercase MIME type sent by non-compliant MUAs such as Pine.

parent b50a782c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -81,7 +81,7 @@ public class MimeBodyPart extends BodyPart {
        if (contentType == null) {
            return "text/plain";
        } else {
            return contentType;
            return contentType.toLowerCase();
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -115,7 +115,7 @@ public class MimeMessage extends Message {
        if (contentType == null) {
            return "text/plain";
        } else {
            return contentType;
            return contentType.toLowerCase();
        }
    }

+7 −4
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.regex.Pattern;
import java.nio.charset.Charset;


@@ -196,7 +197,9 @@ public class MimeUtility {
     * @return
     */
    public static boolean mimeTypeMatches(String mimeType, String matchAgainst) {
        return mimeType.matches(matchAgainst.replaceAll("\\*", "\\.\\*"));
      Pattern p = Pattern.compile(matchAgainst.replaceAll("\\*", "\\.\\*"),
          Pattern.CASE_INSENSITIVE);
      return p.matcher(mimeType).matches();
    }

    /**
@@ -208,7 +211,7 @@ public class MimeUtility {
     */
    public static boolean mimeTypeMatches(String mimeType, String[] matchAgainst) {
        for (String matchType : matchAgainst) {
            if (mimeType.matches(matchType.replaceAll("\\*", "\\.\\*"))) {
          if (mimeTypeMatches(mimeType, matchType)) {
            return true;
          }
        }