mirror of https://github.com/M66B/FairEmail.git
Prefer links to unsubscribe
This commit is contained in:
parent
852b2d5579
commit
cc15eda190
|
@ -592,6 +592,8 @@ public class MessageHelper {
|
|||
if (list != null && list.startsWith("NO"))
|
||||
return null;
|
||||
|
||||
String link = null;
|
||||
String mailto = null;
|
||||
for (String entry : list.split(",")) {
|
||||
entry = entry.trim();
|
||||
int lt = entry.indexOf("<");
|
||||
|
@ -600,12 +602,18 @@ public class MessageHelper {
|
|||
String unsubscribe = entry.substring(lt + 1, gt);
|
||||
Uri uri = Uri.parse(unsubscribe);
|
||||
String scheme = uri.getScheme();
|
||||
if ("mailto".equals(scheme) ||
|
||||
"http".equals(scheme) || "https".equals(scheme))
|
||||
return unsubscribe;
|
||||
if (mailto == null && "mailto".equals(scheme))
|
||||
mailto = unsubscribe;
|
||||
if (link == null && ("http".equals(scheme) || "https".equals(scheme)))
|
||||
link = unsubscribe;
|
||||
}
|
||||
}
|
||||
|
||||
if (link != null)
|
||||
return link;
|
||||
if (mailto != null)
|
||||
return mailto;
|
||||
|
||||
Log.w(new IllegalArgumentException("List-Unsubscribe: " + list));
|
||||
return null;
|
||||
} catch (AddressException ex) {
|
||||
|
|
Loading…
Reference in New Issue