Fixed make POP and Imap more locale safe
Cherry-picks from: https://android-review.googlesource.com/#/c/42334/ https://android-review.googlesource.com/#/c/42332/ Change-Id: I557c3d8c725cf6dc4f13f227dcec63864ab5db67
This commit is contained in:
parent
9fd03edb83
commit
d402c890dc
@ -756,7 +756,7 @@ class ImapFolder extends Folder {
|
||||
|
||||
} else {
|
||||
if (e.isString()) {
|
||||
mp.setSubType(bs.getStringOrEmpty(i).getString().toLowerCase());
|
||||
mp.setSubType(bs.getStringOrEmpty(i).getString().toLowerCase(Locale.US));
|
||||
}
|
||||
break; // Ignore the rest of the list.
|
||||
}
|
||||
@ -781,7 +781,7 @@ class ImapFolder extends Folder {
|
||||
final ImapString type = bs.getStringOrEmpty(0);
|
||||
final ImapString subType = bs.getStringOrEmpty(1);
|
||||
final String mimeType =
|
||||
(type.getString() + "/" + subType.getString()).toLowerCase();
|
||||
(type.getString() + "/" + subType.getString()).toLowerCase(Locale.US);
|
||||
|
||||
final ImapList bodyParams = bs.getListOrEmpty(2);
|
||||
final ImapString cid = bs.getStringOrEmpty(3);
|
||||
@ -839,7 +839,7 @@ class ImapFolder extends Folder {
|
||||
|
||||
if (bodyDisposition.size() > 0) {
|
||||
final String bodyDisposition0Str =
|
||||
bodyDisposition.getStringOrEmpty(0).getString().toLowerCase();
|
||||
bodyDisposition.getStringOrEmpty(0).getString().toLowerCase(Locale.US);
|
||||
if (!TextUtils.isEmpty(bodyDisposition0Str)) {
|
||||
contentDisposition.append(bodyDisposition0Str);
|
||||
}
|
||||
@ -853,9 +853,9 @@ class ImapFolder extends Folder {
|
||||
for (int i = 1, count = bodyDispositionParams.size(); i < count; i += 2) {
|
||||
|
||||
// TODO We need to convert " into %22. See above.
|
||||
contentDisposition.append(String.format(";\n %s=\"%s\"",
|
||||
contentDisposition.append(String.format(Locale.US, ";\n %s=\"%s\"",
|
||||
bodyDispositionParams.getStringOrEmpty(i - 1)
|
||||
.getString().toLowerCase(),
|
||||
.getString().toLowerCase(Locale.US),
|
||||
bodyDispositionParams.getStringOrEmpty(i).getString()));
|
||||
}
|
||||
}
|
||||
@ -864,7 +864,7 @@ class ImapFolder extends Folder {
|
||||
if ((size > 0)
|
||||
&& (MimeUtility.getHeaderParameter(contentDisposition.toString(), "size")
|
||||
== null)) {
|
||||
contentDisposition.append(String.format(";\n size=%d", size));
|
||||
contentDisposition.append(String.format(Locale.US, ";\n size=%d", size));
|
||||
}
|
||||
|
||||
if (contentDisposition.length() > 0) {
|
||||
|
@ -48,6 +48,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Pop3Store extends Store {
|
||||
// All flags defining debug or development code settings must be FALSE
|
||||
@ -559,14 +560,16 @@ public class Pop3Store extends Store {
|
||||
int messageId = mUidToMsgNumMap.get(message.getUid());
|
||||
if (lines == -1) {
|
||||
// Fetch entire message
|
||||
response = executeSimpleCommand(String.format("RETR %d", messageId));
|
||||
response = executeSimpleCommand(String.format(Locale.US, "RETR %d", messageId));
|
||||
} else {
|
||||
// Fetch partial message. Try "TOP", and fall back to slower "RETR" if necessary
|
||||
try {
|
||||
response = executeSimpleCommand(String.format("TOP %d %d", messageId, lines));
|
||||
response = executeSimpleCommand(
|
||||
String.format(Locale.US, "TOP %d %d", messageId, lines));
|
||||
} catch (MessagingException me) {
|
||||
try {
|
||||
response = executeSimpleCommand(String.format("RETR %d", messageId));
|
||||
response = executeSimpleCommand(
|
||||
String.format(Locale.US, "RETR %d", messageId));
|
||||
} catch (MessagingException e) {
|
||||
Log.w(Logging.LOG_TAG, "Can't read message " + messageId);
|
||||
}
|
||||
@ -647,7 +650,7 @@ public class Pop3Store extends Store {
|
||||
try {
|
||||
String uid = message.getUid();
|
||||
int msgNum = mUidToMsgNumMap.get(uid);
|
||||
executeSimpleCommand(String.format("DELE %s", msgNum));
|
||||
executeSimpleCommand(String.format(Locale.US, "DELE %s", msgNum));
|
||||
// Remove from the maps
|
||||
mMsgNumToMsgMap.remove(msgNum);
|
||||
mUidToMsgNumMap.remove(uid);
|
||||
|
Loading…
Reference in New Issue
Block a user