From: Vsevolod Stakhov Date: Tue, 29 Mar 2016 15:08:47 +0000 (+0100) Subject: [Feature] Find URLs with '\r' and '\n' inside href attribute X-Git-Tag: 1.2.2~22 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0fcb6c7dc829b0475b3e99f79072ee01ff0b530c;p=rspamd.git [Feature] Find URLs with '\r' and '\n' inside href attribute --- 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;