1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Content-type case-conversion changes.

Don't convert the content-type to lower case in
MimeMessage.getContentType.  The content-type may have optional parameters
that are case sensitive (boundary, name).

In removing the lower-case conversion from getContentType, a review was
made for inappropriate case-sensitive comparisons which use data obtained
with getContentType.  The only ones found were in isMimeType in both
Message and MimeBodyPart.

Case-sensitive instances of isMimeType were made case-insensitive.  Also,
isMimeType was moved from Message to MimeMessage for symmetry with
MimeBodyPart (MimeMessage & MimeBodyPart are similar and contain a good
bit of duplication such as this).

The unit test required fixing now that the case of the boundary text is
preserved.

References:

Commits 2c5186 and dc4002 added the toLowerCase to getContentType in
MimeMessage & MimeBodyPart (Issue 94).

Later, commit 50cd60 removed the toLowerCase addition from MimeBodyPart
(Issue 1289).
This commit is contained in:
Joe Steele 2013-09-02 18:43:51 -04:00
parent 63f68328ff
commit 1ca1ef5c84
4 changed files with 17 additions and 17 deletions

View File

@ -139,10 +139,6 @@ public abstract class Message implements Part, CompositeBody {
public abstract void setBody(Body body) throws MessagingException;
public boolean isMimeType(String mimeType) throws MessagingException {
return getContentType().startsWith(mimeType);
}
public abstract long getId();
public abstract String getPreview();

View File

@ -122,7 +122,7 @@ public class MimeBodyPart extends BodyPart {
}
public boolean isMimeType(String mimeType) throws MessagingException {
return getMimeType().equals(mimeType);
return getMimeType().equalsIgnoreCase(mimeType);
}
public int getSize() {

View File

@ -164,7 +164,7 @@ public class MimeMessage extends Message {
@Override
public String getContentType() throws MessagingException {
String contentType = getFirstHeader(MimeHeader.HEADER_CONTENT_TYPE);
return (contentType == null) ? "text/plain" : contentType.toLowerCase(Locale.US);
return (contentType == null) ? "text/plain" : contentType;
}
public String getDisposition() throws MessagingException {
@ -177,6 +177,10 @@ public class MimeMessage extends Message {
return MimeUtility.getHeaderParameter(getContentType(), null);
}
public boolean isMimeType(String mimeType) throws MessagingException {
return getMimeType().equalsIgnoreCase(mimeType);
}
public int getSize() {
return mSize;
}

View File

@ -187,10 +187,10 @@ public class MessageTest extends AndroidTestCase {
+ "Subject: Test Message\r\n"
+ "Date: Wed, 28 Aug 2013 08:51:09 -0400\r\n"
+ "MIME-Version: 1.0\r\n"
+ "Content-Type: multipart/mixed; boundary=\"----boundary102\"\r\n"
+ "Content-Type: multipart/mixed; boundary=\"----Boundary102\"\r\n"
+ "Content-Transfer-Encoding: 7bit\r\n"
+ "\r\n"
+ "------boundary102\r\n"
+ "------Boundary102\r\n"
+ "Content-Type: text/plain; charset=utf-8\r\n"
+ "Content-Transfer-Encoding: quoted-printable\r\n"
+ "\r\n"
@ -199,7 +199,7 @@ public class MessageTest extends AndroidTestCase {
+ "=CE=B1=CE=B2=CE=B3=CE=B4=CE=B5=CE=B6=CE=B7=CE=B8\r\n"
+ "End of test=2E\r\n"
+ "\r\n"
+ "------boundary102\r\n"
+ "------Boundary102\r\n"
+ "Content-Type: text/plain; charset=utf-8\r\n"
+ "Content-Transfer-Encoding: quoted-printable\r\n"
+ "\r\n"
@ -208,13 +208,13 @@ public class MessageTest extends AndroidTestCase {
+ "=CE=B1=CE=B2=CE=B3=CE=B4=CE=B5=CE=B6=CE=B7=CE=B8\r\n"
+ "End of test=2E\r\n"
+ "\r\n"
+ "------boundary102\r\n"
+ "------Boundary102\r\n"
+ "Content-Type: application/octet-stream\r\n"
+ "Content-Transfer-Encoding: base64\r\n"
+ "\r\n"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\r\n"
+ "\r\n"
+ "------boundary102\r\n"
+ "------Boundary102\r\n"
+ "Content-Type: message/rfc822\r\n"
+ "Content-Disposition: attachment\r\n"
+ "Content-Transfer-Encoding: 7bit\r\n"
@ -224,10 +224,10 @@ public class MessageTest extends AndroidTestCase {
+ "Subject: Test Message\r\n"
+ "Date: Wed, 28 Aug 2013 08:51:09 -0400\r\n"
+ "MIME-Version: 1.0\r\n"
+ "Content-Type: multipart/mixed; boundary=\"----boundary101\"\r\n"
+ "Content-Type: multipart/mixed; boundary=\"----Boundary101\"\r\n"
+ "Content-Transfer-Encoding: 7bit\r\n"
+ "\r\n"
+ "------boundary101\r\n"
+ "------Boundary101\r\n"
+ "Content-Type: text/plain; charset=utf-8\r\n"
+ "Content-Transfer-Encoding: quoted-printable\r\n"
+ "\r\n"
@ -236,7 +236,7 @@ public class MessageTest extends AndroidTestCase {
+ "=CE=B1=CE=B2=CE=B3=CE=B4=CE=B5=CE=B6=CE=B7=CE=B8\r\n"
+ "End of test=2E\r\n"
+ "\r\n"
+ "------boundary101\r\n"
+ "------Boundary101\r\n"
+ "Content-Type: text/plain; charset=utf-8\r\n"
+ "Content-Transfer-Encoding: quoted-printable\r\n"
+ "\r\n"
@ -245,15 +245,15 @@ public class MessageTest extends AndroidTestCase {
+ "=CE=B1=CE=B2=CE=B3=CE=B4=CE=B5=CE=B6=CE=B7=CE=B8\r\n"
+ "End of test=2E\r\n"
+ "\r\n"
+ "------boundary101\r\n"
+ "------Boundary101\r\n"
+ "Content-Type: application/octet-stream\r\n"
+ "Content-Transfer-Encoding: base64\r\n"
+ "\r\n"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\r\n"
+ "\r\n"
+ "------boundary101--\r\n"
+ "------Boundary101--\r\n"
+ "\r\n"
+ "------boundary102--\r\n"
+ "------Boundary102--\r\n"
+ "\r\n"
+ "------Boundary103--\r\n";