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

Merge pull request #472 from mikeperry-tor/improve-header-privacy

Improve header privacy (Issues 6372, 3559, and 4690)
This commit is contained in:
cketti 2014-06-14 03:02:49 +02:00
commit 59bda357e0
9 changed files with 86 additions and 3 deletions

View File

@ -331,6 +331,8 @@ Please submit bug reports, contribute new features and ask questions at
<string name="global_settings_confirm_action_spam">Spam</string>
<string name="global_settings_confirm_action_delete_notif">Delete (from notification)</string>
<string name="global_settings_privacy_hide_useragent">Remove K-9 User-Agent from mail headers</string>
<string name="global_settings_privacy_hide_timezone">Use UTC as time zone in mail headers</string>
<string name="global_settings_notification_hide_subject_title">Hide subject in notifications</string>
<string name="global_settings_notification_hide_subject_never">Never</string>
<string name="global_settings_notification_hide_subject_when_locked">When device is locked</string>

View File

@ -378,6 +378,16 @@
android:entryValues="@array/global_settings_notification_hide_subject_values"
android:title="@string/global_settings_notification_hide_subject_title"/>
<CheckBoxPreference
android:persistent="false"
android:key="privacy_hide_useragent"
android:title="@string/global_settings_privacy_hide_useragent"/>
<CheckBoxPreference
android:persistent="false"
android:key="privacy_hide_timezone"
android:title="@string/global_settings_privacy_hide_timezone"/>
</PreferenceScreen>
<PreferenceScreen

View File

@ -262,6 +262,8 @@ public class K9 extends Application {
private static String mQuietTimeEnds = null;
private static String mAttachmentDefaultPath = "";
private static boolean mWrapFolderNames = false;
private static boolean mHideUserAgent = false;
private static boolean mHideTimeZone = false;
private static boolean useGalleryBugWorkaround = false;
private static boolean galleryBuggy;
@ -535,6 +537,8 @@ public class K9 extends Application {
editor.putBoolean("messageViewReturnToList", mMessageViewReturnToList);
editor.putBoolean("messageViewShowNext", mMessageViewShowNext);
editor.putBoolean("wrapFolderNames", mWrapFolderNames);
editor.putBoolean("hideUserAgent", mHideUserAgent);
editor.putBoolean("hideTimeZone", mHideTimeZone);
editor.putString("language", language);
editor.putInt("theme", theme.ordinal());
@ -745,6 +749,8 @@ public class K9 extends Application {
mMessageViewReturnToList = sprefs.getBoolean("messageViewReturnToList", false);
mMessageViewShowNext = sprefs.getBoolean("messageViewShowNext", false);
mWrapFolderNames = sprefs.getBoolean("wrapFolderNames", false);
mHideUserAgent = sprefs.getBoolean("hideUserAgent", false);
mHideTimeZone = sprefs.getBoolean("hideTimeZone", false);
useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy());
@ -1274,6 +1280,20 @@ public class K9 extends Application {
mWrapFolderNames = state;
}
public static boolean hideUserAgent() {
return mHideUserAgent;
}
public static void setHideUserAgent(final boolean state) {
mHideUserAgent = state;
}
public static boolean hideTimeZone() {
return mHideTimeZone;
}
public static void setHideTimeZone(final boolean state) {
mHideTimeZone = state;
}
public static String getAttachmentDefaultPath() {
return mAttachmentDefaultPath;
}

View File

@ -1425,7 +1425,10 @@ public class MessageCompose extends K9Activity implements OnClickListener,
message.setHeader("X-Confirm-Reading-To", from.toEncodedString());
message.setHeader("Return-Receipt-To", from.toEncodedString());
}
message.setHeader("User-Agent", getString(R.string.message_header_mua));
if (!K9.hideUserAgent()) {
message.setHeader("User-Agent", getString(R.string.message_header_mua));
}
final String replyTo = mIdentity.getReplyTo();
if (replyTo != null) {

View File

@ -85,6 +85,8 @@ public class Prefs extends K9PreferenceActivity {
private static final String PREFERENCE_QUIET_TIME_STARTS = "quiet_time_starts";
private static final String PREFERENCE_QUIET_TIME_ENDS = "quiet_time_ends";
private static final String PREFERENCE_NOTIF_QUICK_DELETE = "notification_quick_delete";
private static final String PREFERENCE_HIDE_USERAGENT = "privacy_hide_useragent";
private static final String PREFERENCE_HIDE_TIMEZONE = "privacy_hide_timezone";
private static final String PREFERENCE_MESSAGEVIEW_MOBILE_LAYOUT = "messageview_mobile_layout";
private static final String PREFERENCE_AUTOFIT_WIDTH = "messageview_autofit_width";
@ -140,6 +142,8 @@ public class Prefs extends K9PreferenceActivity {
private CheckBoxPreference mUseGalleryBugWorkaround;
private CheckBoxPreference mDebugLogging;
private CheckBoxPreference mSensitiveLogging;
private CheckBoxPreference mHideUserAgent;
private CheckBoxPreference mHideTimeZone;
private CheckBoxPreference mWrapFolderNames;
private CheckBoxListPreference mVisibleRefileActions;
@ -382,9 +386,13 @@ public class Prefs extends K9PreferenceActivity {
mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING);
mSensitiveLogging = (CheckBoxPreference)findPreference(PREFERENCE_SENSITIVE_LOGGING);
mHideUserAgent = (CheckBoxPreference)findPreference(PREFERENCE_HIDE_USERAGENT);
mHideTimeZone = (CheckBoxPreference)findPreference(PREFERENCE_HIDE_TIMEZONE);
mDebugLogging.setChecked(K9.DEBUG);
mSensitiveLogging.setChecked(K9.DEBUG_SENSITIVE);
mHideUserAgent.setChecked(K9.hideUserAgent());
mHideTimeZone.setChecked(K9.hideTimeZone());
mAttachmentPathPreference = findPreference(PREFERENCE_ATTACHMENT_DEF_PATH);
mAttachmentPathPreference.setSummary(K9.getAttachmentDefaultPath());
@ -532,6 +540,8 @@ public class Prefs extends K9PreferenceActivity {
}
K9.DEBUG = mDebugLogging.isChecked();
K9.DEBUG_SENSITIVE = mSensitiveLogging.isChecked();
K9.setHideUserAgent(mHideUserAgent.isChecked());
K9.setHideTimeZone(mHideTimeZone.isChecked());
Editor editor = preferences.edit();
K9.save(editor);

View File

@ -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;
}

View File

@ -8,6 +8,7 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.LinkedList;
import java.util.Locale;
import java.util.Set;
@ -33,6 +34,7 @@ import com.fsck.k9.mail.MessagingException;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.store.UnavailableStorageException;
import com.fsck.k9.K9;
/**
* An implementation of Message that stores all of it's metadata in RFC 822 and
@ -150,6 +152,11 @@ public class MimeMessage extends Message {
if (mDateFormat == null) {
mDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);
}
if (K9.hideTimeZone()) {
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
}
addHeader("Date", mDateFormat.format(sentDate));
setInternalSentDate(sentDate);
}
@ -313,7 +320,22 @@ public class MimeMessage extends Message {
}
private String generateMessageId() {
return "<" + UUID.randomUUID().toString() + "@email.android.com>";
String hostname = null;
if (mFrom != null && mFrom.length >= 1) {
hostname = mFrom[0].getHostname();
}
if (hostname == null && mReplyTo != null && mReplyTo.length >= 1) {
hostname = mReplyTo[0].getHostname();
}
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 {

View File

@ -249,6 +249,12 @@ public class GlobalSettings {
s.put("fontSizeMessageViewContentPercent", Settings.versions(
new V(31, new IntegerRangeSetting(40, 250, 100))
));
s.put("hideUserAgent", Settings.versions(
new V(32, new BooleanSetting(false))
));
s.put("hideTimeZone", Settings.versions(
new V(32, new BooleanSetting(false))
));
SETTINGS = Collections.unmodifiableMap(s);

View File

@ -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,