commit b78a75c: [Rework] Rework extended urls output

Vsevolod Stakhov vsevolod at highsecure.ru
Mon Apr 19 16:28:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-04-19 17:20:02 +0100
URL: https://github.com/rspamd/rspamd/commit/b78a75ca179f30eca99b51ef88e927c85e59694b

[Rework] Rework extended urls output

---
 src/libserver/protocol.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c
index 878f0bb3e..e7f4dbd50 100644
--- a/src/libserver/protocol.c
+++ b/src/libserver/protocol.c
@@ -889,11 +889,16 @@ rspamd_protocol_extended_url (struct rspamd_task *task,
 		ucl_object_insert_key (obj, elt, "host", 0, false);
 	}
 
-	elt = ucl_object_frombool (url->flags & RSPAMD_URL_FLAG_PHISHED);
-	ucl_object_insert_key (obj, elt, "phished", 0, false);
+	ucl_object_t *flags = ucl_object_typed_new (UCL_ARRAY);
 
-	elt = ucl_object_frombool (url->flags & RSPAMD_URL_FLAG_REDIRECTED);
-	ucl_object_insert_key (obj, elt, "redirected", 0, false);
+	for (unsigned int i = 0; i < RSPAMD_URL_MAX_FLAG_SHIFT; i ++) {
+		if (url->flags & (1u << i)) {
+			ucl_object_t *fl = ucl_object_fromstring (rspamd_url_flag_to_string (1u << i));
+			ucl_array_append (flags, fl);
+		}
+	}
+
+	ucl_object_insert_key (obj, flags, "flags", 0, false);
 
 	if (url->linked_url) {
 		encoded = rspamd_url_encode (url->linked_url, &enclen, task->task_pool);


More information about the Commits mailing list