Handle unclosed HTML tags properly.
Remove warnings for types on 32 bit archs.
Do not touch grow factor many times when one shot mode is turned on.
struct rspamd_dns_request *req = arg;
event_del (&req->timer_event);
- g_hash_table_remove (req->resolver->requests, GUINT_TO_POINTER (req->id));
+ g_hash_table_remove (req->resolver->requests, GUINT_TO_POINTER ((guint)req->id));
}
static guint8 *
}
/* Now try to find corresponding request */
- if ((req = g_hash_table_lookup (resolver->requests, GUINT_TO_POINTER (header->qid))) == NULL) {
+ if ((req = g_hash_table_lookup (resolver->requests, GUINT_TO_POINTER ((guint)header->qid))) == NULL) {
/* No such requests found */
return FALSE;
}
evtimer_add (&req->timer_event, &req->tv);
/* Add request to hash table */
- g_hash_table_insert (req->resolver->requests, GUINT_TO_POINTER (req->id), req);
+ g_hash_table_insert (req->resolver->requests, GUINT_TO_POINTER ((guint)req->id), req);
register_async_event (req->session, (event_finalizer_t)dns_fin_cb, req, FALSE);
}
}
evtimer_add (&req->timer_event, &req->tv);
/* Add request to hash table */
- g_hash_table_insert (resolver->requests, GUINT_TO_POINTER (req->id), req);
+ g_hash_table_insert (resolver->requests, GUINT_TO_POINTER ((guint)req->id), req);
register_async_event (session, (event_finalizer_t)dns_fin_cb, req, FALSE);
}
else if (r == -1) {
else {
w = (*weight) * flag;
}
- /* Handle grow factor */
- if (metric_res->grow_factor && w > 0) {
- w *= metric_res->grow_factor;
- metric_res->grow_factor *= metric->grow_factor;
- }
- else if (w > 0) {
- metric_res->grow_factor = metric->grow_factor;
- }
-
- /* Add metric score */
+ /* Add metric score */
if ((s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) {
if (s->options && opts && opts != s->options) {
/* Append new options */
memory_pool_add_destructor (task->task_pool, (pool_destruct_func) g_list_free, s->options);
}
if (!single) {
+ /* Handle grow factor */
+ if (metric_res->grow_factor && w > 0) {
+ w *= metric_res->grow_factor;
+ metric_res->grow_factor *= metric->grow_factor;
+ }
+ else if (w > 0) {
+ metric_res->grow_factor = metric->grow_factor;
+ }
s->score += w;
metric_res->score += w;
}
s = memory_pool_alloc (task->task_pool, sizeof (struct symbol));
s->score = w;
+ /* Handle grow factor */
+ if (metric_res->grow_factor && w > 0) {
+ w *= metric_res->grow_factor;
+ metric_res->grow_factor *= metric->grow_factor;
+ }
+ else if (w > 0) {
+ metric_res->grow_factor = metric->grow_factor;
+ }
s->name = symbol;
metric_res->score += w;
html_strncasestr (const gchar *s, const gchar *find, gsize len)
{
gchar c, sc;
- size_t mlen;
+ gsize mlen;
if ((c = *find++) != 0) {
c = g_ascii_tolower (c);
p = url_text;
while (len < remain) {
if (*p == '<') {
- /* Get tag name */
- p ++;
- len ++;
- if (*p == '/') {
- /* Check tag name */
+ /* Check tag name */
+ if (*(p + 1) == '/') {
+ c = p + 2;
+ }
+ else {
c = p + 1;
- while (len < remain) {
- if (!g_ascii_isspace (*p) && *p != '>') {
+ }
+ while (len < remain) {
+ if (!g_ascii_isspace (*p) && *p != '>') {
+ p ++;
+ len ++;
+ }
+ else {
+ break;
+ }
+ }
+ rspamd_strlcpy (tagbuf, c, MIN (sizeof(tagbuf), p - c + 1));
+ if ((tag = get_tag_by_name (tagbuf)) != NULL) {
+ if (tag->id == id) {
+ break;
+ }
+ else if (tag->id == Tag_IMG) {
+ /* We should ignore IMG tag here */
+ while (len < remain && *p != '>' && *p != '<') {
p ++;
len ++;
}
- else {
- break;
- }
- }
- rspamd_strlcpy (tagbuf, c, MIN (sizeof(tagbuf), p - c + 1));
- if ((tag = get_tag_by_name (tagbuf)) != NULL) {
- if (tag->id == id) {
- break;
+ if (*p == '>' && len < remain) {
+ p ++;
}
+
+ remain -= p - url_text;
+ url_text = p;
+ len = 0;
+ continue;
}
}
}
if (new != NULL) {
g_strstrip (url_str);
rc = parse_uri (new, url_str, task->task_pool);
+
if (rc == URI_ERRNO_OK || rc == URI_ERRNO_NO_SLASHES || rc == URI_ERRNO_NO_HOST_SLASH) {
if (g_ascii_strncasecmp (href_url->host, new->host,
MAX (href_url->hostlen, new->hostlen)) != 0) {
state = 1;
}
else if (state == 1) {
- depth++;
+ /* Opening bracket without closing one */
+ p --;
+ while (g_ascii_isspace (*p) && p > src->data) {
+ p --;
+ }
+ p ++;
+ goto unbreak_tag;
}
break;
if (in_q) {
break;
}
-
+unbreak_tag:
switch (state) {
case 1: /* HTML/XML */
lc = '>';