Fix spaces in list unsubscribe

master
M66B 3 weeks ago
parent b164c38f44
commit 0b42bc22ad

@ -87,6 +87,7 @@ public class FragmentDialogUnsubscribe extends FragmentDialogBase {
protected String onExecute(Context context, Bundle args) throws Throwable { protected String onExecute(Context context, Bundle args) throws Throwable {
final String uri = args.getString("uri"); final String uri = args.getString("uri");
final String request = "List-Unsubscribe=One-Click"; final String request = "List-Unsubscribe=One-Click";
Log.i("Unsubscribe request=" + request + " uri=" + uri);
// https://datatracker.ietf.org/doc/html/rfc8058 // https://datatracker.ietf.org/doc/html/rfc8058
@ -108,10 +109,12 @@ public class FragmentDialogUnsubscribe extends FragmentDialogBase {
int status = connection.getResponseCode(); int status = connection.getResponseCode();
if (status < 200 || status > 299) { if (status < 200 || status > 299) {
String error = "Error " + status + ": " + connection.getResponseMessage(); String error = "Error " + status + ": " + connection.getResponseMessage();
Log.i("Unsubscribe error=" + error);
InputStream stream = connection.getErrorStream(); InputStream stream = connection.getErrorStream();
String detail = (stream == null ? null : Helper.readStream(stream)); String detail = (stream == null || status == 404 ? null : Helper.readStream(stream));
throw new IOException(error + " " + detail); throw new IOException(error + " " + detail);
} } else
Log.i("Unsubscribe status=" + status);
return Helper.readStream(connection.getInputStream()); return Helper.readStream(connection.getInputStream());
} finally { } finally {

@ -2975,6 +2975,7 @@ public class MessageHelper {
list = MimeUtility.unfold(list); list = MimeUtility.unfold(list);
list = decodeMime(list); list = decodeMime(list);
list = list.replaceAll("\\s+", "");
if (list == null || list.startsWith("NO")) if (list == null || list.startsWith("NO"))
return null; return null;
@ -2985,6 +2986,7 @@ public class MessageHelper {
if (post != null) { if (post != null) {
post = MimeUtility.unfold(post); post = MimeUtility.unfold(post);
post = decodeMime(post); post = decodeMime(post);
post = post.replaceAll("\\s+", "");
oneclick = "List-Unsubscribe=One-Click".equalsIgnoreCase(post.trim()); oneclick = "List-Unsubscribe=One-Click".equalsIgnoreCase(post.trim());
} }

Loading…
Cancel
Save