DMARC viewer improvements

pull/207/head
M66B 3 years ago
parent 0f0f94ba6f
commit 3810533334

@ -205,6 +205,8 @@ public class ActivityDmarc extends ActivityBase {
eventType = xml.next(); eventType = xml.next();
if (eventType == XmlPullParser.TEXT) { if (eventType == XmlPullParser.TEXT) {
String text = xml.getText(); String text = xml.getText();
if (text == null)
text = "<null>";
if ("begin".equals(name) || "end".equals(name)) { if ("begin".equals(name) || "end".equals(name)) {
text = text.trim(); text = text.trim();
try { try {
@ -224,8 +226,12 @@ public class ActivityDmarc extends ActivityBase {
case "domain": case "domain":
if (feedback && (policy_published || auth_results)) { if (feedback && (policy_published || auth_results)) {
eventType = xml.next(); eventType = xml.next();
if (eventType == XmlPullParser.TEXT) if (eventType == XmlPullParser.TEXT) {
ssb.append(xml.getText()).append(' '); String text = xml.getText();
if (text == null)
text = "<null>";
ssb.append(text).append(' ');
}
} }
break; break;
case "adkim": case "adkim":
@ -233,11 +239,16 @@ public class ActivityDmarc extends ActivityBase {
case "p": case "p":
case "sp": case "sp":
case "pct": case "pct":
case "fo":
if (feedback && policy_published) { if (feedback && policy_published) {
eventType = xml.next(); eventType = xml.next();
if (eventType == XmlPullParser.TEXT) if (eventType == XmlPullParser.TEXT) {
String text = xml.getText();
if (text == null)
text = "<null>";
ssb.append(name).append('=') ssb.append(name).append('=')
.append(xml.getText()).append(' '); .append(text).append(' ');
}
} }
break; break;
case "source_ip": case "source_ip":
@ -245,8 +256,11 @@ public class ActivityDmarc extends ActivityBase {
if (feedback && record && row) { if (feedback && record && row) {
eventType = xml.next(); eventType = xml.next();
if (eventType == XmlPullParser.TEXT) { if (eventType == XmlPullParser.TEXT) {
String text = xml.getText();
if (text == null)
text = "<null>";
ssb.append(name).append('=') ssb.append(name).append('=')
.append(xml.getText()).append(' '); .append(text).append(' ');
} }
} }
break; break;
@ -254,6 +268,8 @@ public class ActivityDmarc extends ActivityBase {
case "dkim": case "dkim":
case "spf": case "spf":
case "header_from": case "header_from":
case "envelope_from":
case "envelope_to":
if (feedback && record) if (feedback && record)
if (policy_evaluated || identifiers) { if (policy_evaluated || identifiers) {
eventType = xml.next(); eventType = xml.next();
@ -261,8 +277,10 @@ public class ActivityDmarc extends ActivityBase {
ssb.append(name).append('='); ssb.append(name).append('=');
int start = ssb.length(); int start = ssb.length();
String text = xml.getText(); String text = xml.getText();
if (text == null)
text = "<null>";
ssb.append(text); ssb.append(text);
if (!"pass".equals(text) && if (!"pass".equals(text.toLowerCase(Locale.ROOT)) &&
("dkim".equals(name) || "spf".equals(name))) { ("dkim".equals(name) || "spf".equals(name))) {
ssb.setSpan(new ForegroundColorSpan(colorWarning), start, ssb.length(), 0); ssb.setSpan(new ForegroundColorSpan(colorWarning), start, ssb.length(), 0);
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0); ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
@ -279,8 +297,10 @@ public class ActivityDmarc extends ActivityBase {
ssb.append(result == null ? "?" : result).append('='); ssb.append(result == null ? "?" : result).append('=');
int start = ssb.length(); int start = ssb.length();
String text = xml.getText(); String text = xml.getText();
if (text == null)
text = "<null>";
ssb.append(text); ssb.append(text);
if (!"pass".equals(text)) { if (!"pass".equals(text.toLowerCase(Locale.ROOT))) {
ssb.setSpan(new ForegroundColorSpan(colorWarning), start, ssb.length(), 0); ssb.setSpan(new ForegroundColorSpan(colorWarning), start, ssb.length(), 0);
ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0); ssb.setSpan(new StyleSpan(Typeface.BOLD), start, ssb.length(), 0);
} }
@ -292,9 +312,13 @@ public class ActivityDmarc extends ActivityBase {
case "scope": case "scope":
if (feedback && auth_results) { if (feedback && auth_results) {
eventType = xml.next(); eventType = xml.next();
if (eventType == XmlPullParser.TEXT) if (eventType == XmlPullParser.TEXT) {
String text = xml.getText();
if (text == null)
text = "<null>";
ssb.append(name).append('=') ssb.append(name).append('=')
.append(xml.getText()).append(' '); .append(text).append(' ');
}
} }
break; break;
} }
@ -380,11 +404,8 @@ public class ActivityDmarc extends ActivityBase {
@Override @Override
protected void onException(Bundle args, @NonNull Throwable ex) { protected void onException(Bundle args, @NonNull Throwable ex) {
if (ex instanceof IllegalArgumentException && !BuildConfig.DEBUG) tvDmarc.setText(ex + "\n" + android.util.Log.getStackTraceString(ex));
Snackbar.make(findViewById(android.R.id.content), ex.getMessage(), Snackbar.LENGTH_LONG) grpReady.setVisibility(View.VISIBLE);
.setGestureInsetBottomIgnored(true).show();
else
Log.unexpectedError(getSupportFragmentManager(), ex, false);
} }
}.execute(this, args, "dmarc:decode"); }.execute(this, args, "dmarc:decode");
} }

Loading…
Cancel
Save