mirror of
https://github.com/moparisthebest/k-9
synced 2024-12-02 14:02:17 -05:00
Issue 190
Handle uppercase MIME type sent by non-compliant MUAs such as Pine.
This commit is contained in:
parent
b50a782c1c
commit
2c51862087
@ -81,7 +81,7 @@ public class MimeBodyPart extends BodyPart {
|
|||||||
if (contentType == null) {
|
if (contentType == null) {
|
||||||
return "text/plain";
|
return "text/plain";
|
||||||
} else {
|
} else {
|
||||||
return contentType;
|
return contentType.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public class MimeMessage extends Message {
|
|||||||
if (contentType == null) {
|
if (contentType == null) {
|
||||||
return "text/plain";
|
return "text/plain";
|
||||||
} else {
|
} else {
|
||||||
return contentType;
|
return contentType.toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
|
|
||||||
@ -196,7 +197,9 @@ public class MimeUtility {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean mimeTypeMatches(String mimeType, String matchAgainst) {
|
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) {
|
public static boolean mimeTypeMatches(String mimeType, String[] matchAgainst) {
|
||||||
for (String matchType : matchAgainst) {
|
for (String matchType : matchAgainst) {
|
||||||
if (mimeType.matches(matchType.replaceAll("\\*", "\\.\\*"))) {
|
if (mimeTypeMatches(mimeType, matchType)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user