]> source.dussan.org Git - rspamd.git/commitdiff
* Strip urls from space characters
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 5 Aug 2009 11:29:20 +0000 (15:29 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 5 Aug 2009 11:29:20 +0000 (15:29 +0400)
src/html.c
src/url.c

index 89196264324d898caaa8549e8795a34f282e5b97..8f5664079fc1a5a5e5686d828ad0a1fa5afd503e 100644 (file)
@@ -394,7 +394,6 @@ parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t i
                
                url_text = memory_pool_alloc (task->task_pool, len + 1);
                g_strlcpy (url_text, c, len + 1);
-               g_strstrip (url_text);
                decode_entitles (url_text);
                url = memory_pool_alloc (task->task_pool, sizeof (struct uri));
                rc = parse_uri (url, url_text, task->task_pool);
index e11d30f820a2a5d79c5640831ef41f45d901d857..c089f42755b8e625fa5cde33714b58666ee7da02 100644 (file)
--- a/src/url.c
+++ b/src/url.c
@@ -400,6 +400,22 @@ url_unescape (char *s)
        *t = '\0';
 }
 
+static void
+url_strip (char *s)
+{
+       char *t = s;                    /* t - tortoise */
+       char *h = s;                    /* h - hare     */
+
+    while (*h) {
+        if (g_ascii_isgraph (*h)) {
+            *t = *h;
+            t ++;
+        }
+        h++;
+    }
+    *t = '\0';
+}
+
 /* The core of url_escape_* functions.  Escapes the characters that
    match the provided mask in urlchr_table.
 
@@ -870,6 +886,8 @@ parse_uri(struct uri *uri, unsigned char *uristring, memory_pool_t *pool)
        if (strchr (uri->host, '%')) {
                uri->hostlen = url_calculate_escaped_hostlen (uri->host, uri->hostlen);
        }
+
+       url_strip (struri (uri));
        url_unescape (uri->host);
 
        path_simplify (uri->data);