From 0fcb6c7dc829b0475b3e99f79072ee01ff0b530c Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 29 Mar 2016 16:08:47 +0100 Subject: [PATCH] [Feature] Find URLs with '\r' and '\n' inside href attribute --- src/libserver/html.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libserver/html.c b/src/libserver/html.c index b799e9280..49034acf6 100644 --- a/src/libserver/html.c +++ b/src/libserver/html.c @@ -1131,6 +1131,7 @@ rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len, gsize decoded_len; gboolean has_spaces = FALSE; const gchar *p; + gchar *t, *h; p = start; @@ -1166,6 +1167,21 @@ rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len, rspamd_strlcpy (decoded, start, len + 1); decoded_len = rspamd_decode_url (decoded, start, len); + /* We also need to remove all internal newlines */ + t = decoded; + h = t; + + while (*h) { + if (*h == '\r' || *h == '\n') { + h ++; + decoded_len --; + } + else { + *t++ = *h++; + } + } + *t = *h; + if (comp) { comp->start = decoded; comp->len = decoded_len; -- 2.39.5