Fixes for cketti's code review on pull req #472
Leave the hostname == null checks so we can fall back if a hostname is not found. Also convert message-id to upper case to match Apple Mail (for privacy).
This commit is contained in:
parent
38c90146e1
commit
d67a59b77f
3 changed files with 21 additions and 11 deletions
|
@ -93,6 +93,16 @@ public class Address {
|
|||
return mAddress;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
int hostIdx = mAddress.lastIndexOf("@");
|
||||
|
||||
if (hostIdx == -1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mAddress.substring(hostIdx+1);
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.mAddress = address;
|
||||
}
|
||||
|
|
|
@ -321,21 +321,21 @@ public class MimeMessage extends Message {
|
|||
|
||||
private String generateMessageId() {
|
||||
String hostname = null;
|
||||
if (mFrom != null) {
|
||||
int hostIdx = mFrom[0].getAddress().lastIndexOf("@");
|
||||
hostname = mFrom[0].getAddress().substring(hostIdx);
|
||||
|
||||
if (mFrom != null && mFrom.length >= 1) {
|
||||
hostname = mFrom[0].getHostname();
|
||||
}
|
||||
|
||||
if (hostname == null && mReplyTo != null) {
|
||||
int hostIdx = mReplyTo[0].getAddress().lastIndexOf("@");
|
||||
hostname = mReplyTo[0].getAddress().substring(hostIdx);
|
||||
if (hostname == null && mReplyTo != null && mReplyTo.length >= 1) {
|
||||
hostname = mReplyTo[0].getHostname();
|
||||
}
|
||||
|
||||
if (hostname != null) {
|
||||
return "<" + UUID.randomUUID().toString() + hostname + ">";
|
||||
} else {
|
||||
return "<" + UUID.randomUUID().toString() + "@email.android.com>";
|
||||
if (hostname == null) {
|
||||
hostname = "email.android.com";
|
||||
}
|
||||
|
||||
/* We use upper case here to match Apple Mail Message-ID format (for privacy) */
|
||||
return "<" + UUID.randomUUID().toString().toUpperCase(Locale.US) + "@" + hostname + ">";
|
||||
}
|
||||
|
||||
public void setMessageId(String messageId) throws UnavailableStorageException {
|
||||
|
|
|
@ -35,7 +35,7 @@ public class Settings {
|
|||
*
|
||||
* @see SettingsExporter
|
||||
*/
|
||||
public static final int VERSION = 31;
|
||||
public static final int VERSION = 32;
|
||||
|
||||
public static Map<String, Object> validate(int version, Map<String,
|
||||
TreeMap<Integer, SettingsDescription>> settings,
|
||||
|
|
Loading…
Reference in a new issue