]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Find URLs with '\r' and '\n' inside href attribute
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Mar 2016 15:08:47 +0000 (16:08 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 29 Mar 2016 15:08:47 +0000 (16:08 +0100)
src/libserver/html.c

index b799e9280c029273cc81a5e9fcea5cb3fcbd101a..49034acf668d5031642a2860e40e8ba38358701e 100644 (file)
@@ -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;