commit e8437ef: [Minor] Fix simple regexps

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Jul 29 10:07:07 UTC 2020


Author: Vsevolod Stakhov
Date: 2020-07-29 11:00:42 +0100
URL: https://github.com/rspamd/rspamd/commit/e8437ef00ffc2c6866ff28deaae001cf83dbcba2 (HEAD -> master)

[Minor] Fix simple regexps

---
 src/libmime/mime_expressions.c | 47 +++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/src/libmime/mime_expressions.c b/src/libmime/mime_expressions.c
index 0caa324cc..d35bc136f 100644
--- a/src/libmime/mime_expressions.c
+++ b/src/libmime/mime_expressions.c
@@ -815,41 +815,36 @@ set:
 			goto err;
 		}
 		else {
-			const ucl_object_t *re_conditions = ucl_object_lookup (real_ud->conf_obj,
-					"re_conditions");
 			gint lua_cbref = -1;
 
 			/* Check regexp condition */
-			if (real_ud->conf_obj == NULL) {
-				g_set_error (err, rspamd_mime_expr_quark(), 300,
-						"no config object for '%s'",
-						mime_atom->str);
-				goto err;
-			}
+			if (real_ud->conf_obj != NULL) {
+				const ucl_object_t *re_conditions = ucl_object_lookup (real_ud->conf_obj,
+						"re_conditions");
+
+				if (re_conditions != NULL) {
+					if (ucl_object_type (re_conditions) != UCL_OBJECT) {
+						g_set_error (err, rspamd_mime_expr_quark (), 320,
+								"re_conditions is not a table for '%s'",
+								mime_atom->str);
+						goto err;
+					}
 
-			if (re_conditions != NULL) {
-				if (ucl_object_type (re_conditions) != UCL_OBJECT) {
-					g_set_error (err, rspamd_mime_expr_quark(), 320,
-							"re_conditions is not a table for '%s'",
+					const ucl_object_t *function_obj = ucl_object_lookup (re_conditions,
 							mime_atom->str);
-					goto err;
-				}
 
-				const ucl_object_t *function_obj;
+					if (function_obj != NULL) {
+						if (ucl_object_type (function_obj) != UCL_USERDATA) {
+							g_set_error (err, rspamd_mime_expr_quark (), 320,
+									"condition for '%s' is invalid, must be function",
+									mime_atom->str);
+							goto err;
+						}
 
-				function_obj = ucl_object_lookup (re_conditions, mime_atom->str);
+						struct ucl_lua_funcdata *fd = function_obj->value.ud;
 
-				if (function_obj != NULL) {
-					if (ucl_object_type (function_obj) != UCL_USERDATA) {
-						g_set_error (err, rspamd_mime_expr_quark(), 320,
-								"condition for '%s' is invalid, must be function",
-								mime_atom->str);
-						goto err;
+						lua_cbref = fd->idx;
 					}
-
-					struct ucl_lua_funcdata *fd = function_obj->value.ud;
-
-					lua_cbref = fd->idx;
 				}
 			}
 


More information about the Commits mailing list