Perform case-insensitive matches in mimeTypeMatches to support User-Agent's which use uppercased Content-Type. (fixed formatting)
This commit is contained in:
parent
8978aac197
commit
14fe30f3bf
@ -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 org.apache.commons.io.IOUtils;
|
||||
import org.apache.james.mime4j.decoder.Base64InputStream;
|
||||
@ -189,7 +190,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,7 +204,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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user