|
|
@ -239,25 +239,46 @@ public class EntityRule {
|
|
|
|
String value = jheader.getString("value");
|
|
|
|
String value = jheader.getString("value");
|
|
|
|
boolean regex = jheader.getBoolean("regex");
|
|
|
|
boolean regex = jheader.getBoolean("regex");
|
|
|
|
|
|
|
|
|
|
|
|
boolean matches = false;
|
|
|
|
if (!regex &&
|
|
|
|
Enumeration<Header> headers;
|
|
|
|
value != null &&
|
|
|
|
if (imessage != null)
|
|
|
|
value.startsWith("$") &&
|
|
|
|
headers = imessage.getAllHeaders();
|
|
|
|
value.endsWith("$")) {
|
|
|
|
else if (message.headers != null) {
|
|
|
|
String keyword = value.substring(1, value.length() - 1);
|
|
|
|
ByteArrayInputStream bis = new ByteArrayInputStream(message.headers.getBytes());
|
|
|
|
|
|
|
|
headers = new InternetHeaders(bis).getAllHeaders();
|
|
|
|
List<String> keywords = new ArrayList<>();
|
|
|
|
} else
|
|
|
|
if (message.ui_seen)
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_rule_no_headers));
|
|
|
|
keywords.add("$seen");
|
|
|
|
while (headers.hasMoreElements()) {
|
|
|
|
if (message.ui_answered)
|
|
|
|
Header header = headers.nextElement();
|
|
|
|
keywords.add("$answered");
|
|
|
|
String formatted = header.getName() + ": " + header.getValue();
|
|
|
|
if (message.ui_flagged)
|
|
|
|
if (matches(context, message, value, formatted, regex)) {
|
|
|
|
keywords.add("$flagged");
|
|
|
|
matches = true;
|
|
|
|
if (message.ui_deleted)
|
|
|
|
break;
|
|
|
|
keywords.add("$deleted");
|
|
|
|
|
|
|
|
keywords.addAll(Arrays.asList(message.keywords));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!keywords.contains(keyword))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
boolean matches = false;
|
|
|
|
|
|
|
|
Enumeration<Header> headers;
|
|
|
|
|
|
|
|
if (imessage != null)
|
|
|
|
|
|
|
|
headers = imessage.getAllHeaders();
|
|
|
|
|
|
|
|
else if (message.headers != null) {
|
|
|
|
|
|
|
|
ByteArrayInputStream bis = new ByteArrayInputStream(message.headers.getBytes());
|
|
|
|
|
|
|
|
headers = new InternetHeaders(bis).getAllHeaders();
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
throw new IllegalArgumentException(context.getString(R.string.title_rule_no_headers));
|
|
|
|
|
|
|
|
while (headers.hasMoreElements()) {
|
|
|
|
|
|
|
|
Header header = headers.nextElement();
|
|
|
|
|
|
|
|
String formatted = header.getName() + ": " + header.getValue();
|
|
|
|
|
|
|
|
if (matches(context, message, value, formatted, regex)) {
|
|
|
|
|
|
|
|
matches = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!matches)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!matches)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Date
|
|
|
|
// Date
|
|
|
|