From 91144624bf991c4ff10a656ca493fc6bb7cab4a5 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 18 Aug 2026 17:43:27 +0200 Subject: [PATCH] Validate rule regex'es --- .../java/eu/faircode/email/EntityRule.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/EntityRule.java b/app/src/main/java/eu/faircode/email/EntityRule.java index 656c5331be..bd537d5d2d 100644 --- a/app/src/main/java/eu/faircode/email/EntityRule.java +++ b/app/src/main/java/eu/faircode/email/EntityRule.java @@ -713,6 +713,29 @@ public class EntityRule { throw new IllegalArgumentException(message, ex); } + JSONObject jcondition = new JSONObject(condition); + + JSONObject jsender = jcondition.optJSONObject("sender"); + JSONObject jrecipient = jcondition.optJSONObject("recipient"); + JSONObject jsubject = jcondition.optJSONObject("subject"); + JSONObject jheader = jcondition.optJSONObject("header"); + JSONObject jbody = jcondition.optJSONObject("body"); + + if (jsender != null && jsender.optBoolean("regex")) + Pattern.compile(jsender.optString("value")); + + if (jrecipient != null && jrecipient.optBoolean("regex")) + Pattern.compile(jrecipient.optString("value")); + + if (jsubject != null && jsubject.optBoolean("regex")) + Pattern.compile(jsubject.optString("value")); + + if (jheader != null && jheader.optBoolean("regex")) + Pattern.compile(jheader.optString("value")); + + if (jbody != null && jbody.optBoolean("regex")) + Pattern.compile(jbody.optString("value")); + JSONObject jargs = new JSONObject(action); int type = jargs.getInt("type");