1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-11 20:15:03 -05:00

Issue 190

Handle uppercase MIME type sent by non-compliant MUAs such as Pine.
This commit is contained in:
Daniel Applebaum 2009-01-18 16:31:37 +00:00
parent b50a782c1c
commit 2c51862087
3 changed files with 9 additions and 6 deletions

View File

@ -81,7 +81,7 @@ public class MimeBodyPart extends BodyPart {
if (contentType == null) {
return "text/plain";
} else {
return contentType;
return contentType.toLowerCase();
}
}

View File

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

View File

@ -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,9 +211,9 @@ public class MimeUtility {
*/
public static boolean mimeTypeMatches(String mimeType, String[] matchAgainst) {
for (String matchType : matchAgainst) {
if (mimeType.matches(matchType.replaceAll("\\*", "\\.\\*"))) {
return true;
}
if (mimeTypeMatches(mimeType, matchType)) {
return true;
}
}
return false;
}