mirror of https://github.com/M66B/FairEmail.git
Expression: fixed text
This commit is contained in:
parent
441812c561
commit
710fd04781
|
@ -204,7 +204,7 @@ public class EntityRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (jcondition.has("expression")) {
|
if (jcondition.has("expression")) {
|
||||||
Expression expression = getExpression(rule, null, null, null);
|
Expression expression = getExpression(rule, null, null, null, null);
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
if ("header".equals(what) && needsHeaders(expression))
|
if ("header".equals(what) && needsHeaders(expression))
|
||||||
return true;
|
return true;
|
||||||
|
@ -484,6 +484,7 @@ public class EntityRule {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Younger
|
||||||
if (jcondition.has("younger")) {
|
if (jcondition.has("younger")) {
|
||||||
int younger = jcondition.getInt("younger");
|
int younger = jcondition.getInt("younger");
|
||||||
Calendar y = Calendar.getInstance();
|
Calendar y = Calendar.getInstance();
|
||||||
|
@ -493,7 +494,7 @@ public class EntityRule {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expression
|
// Expression
|
||||||
Expression expression = getExpression(this, message, headers, context);
|
Expression expression = getExpression(this, message, headers, html, context);
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
boolean experiments = prefs.getBoolean("experiments", false);
|
boolean experiments = prefs.getBoolean("experiments", false);
|
||||||
|
@ -700,7 +701,7 @@ public class EntityRule {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Expression getExpression(EntityRule rule, EntityMessage message, List<Header> headers, Context context) throws JSONException, ParseException, MessagingException {
|
static Expression getExpression(EntityRule rule, EntityMessage message, List<Header> headers, String html, Context context) throws JSONException, ParseException, MessagingException {
|
||||||
// https://ezylang.github.io/EvalEx/
|
// https://ezylang.github.io/EvalEx/
|
||||||
|
|
||||||
JSONObject jcondition = new JSONObject(rule.condition);
|
JSONObject jcondition = new JSONObject(rule.condition);
|
||||||
|
@ -718,14 +719,15 @@ public class EntityRule {
|
||||||
for (Address a : message.from)
|
for (Address a : message.from)
|
||||||
from.add(MessageHelper.formatAddresses(new Address[]{a}));
|
from.add(MessageHelper.formatAddresses(new Address[]{a}));
|
||||||
|
|
||||||
Document doc = null;
|
if (html == null && message != null && message.content)
|
||||||
if (message != null && message.content)
|
|
||||||
try {
|
try {
|
||||||
doc = JsoupEx.parse(message.getFile(context));
|
html = Helper.readText(message.getFile(context));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Log.e(ex);
|
Log.e(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Document doc = (html == null ? null : JsoupEx.parse(html));
|
||||||
|
|
||||||
if (headers == null && message != null && message.headers != null) {
|
if (headers == null && message != null && message.headers != null) {
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(message.headers.getBytes());
|
ByteArrayInputStream bis = new ByteArrayInputStream(message.headers.getBytes());
|
||||||
headers = Collections.list(new InternetHeaders(bis, true).getAllHeaders());
|
headers = Collections.list(new InternetHeaders(bis, true).getAllHeaders());
|
||||||
|
@ -850,7 +852,7 @@ public class EntityRule {
|
||||||
|
|
||||||
void validate(Context context) throws JSONException, IllegalArgumentException {
|
void validate(Context context) throws JSONException, IllegalArgumentException {
|
||||||
try {
|
try {
|
||||||
Expression expression = getExpression(this, null, null, context);
|
Expression expression = getExpression(this, null, null, null, context);
|
||||||
if (expression != null) {
|
if (expression != null) {
|
||||||
for (String variable : expression.getUsedVariables()) {
|
for (String variable : expression.getUsedVariables()) {
|
||||||
Log.i("EXPR variable=" + variable);
|
Log.i("EXPR variable=" + variable);
|
||||||
|
|
Loading…
Reference in New Issue