gint off, rc;
p = url_text;
- while (len < remain) {
+ while (len < remain - 1) {
if (*p == '<' || *p == '>') {
break;
}
}
static void
-parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t id, gchar *tag_text, gsize tag_len)
+parse_tag_url (struct worker_task *task, struct mime_text_part *part, tag_id_t id,
+ gchar *tag_text, gsize tag_len, gsize remain)
{
gchar *c = NULL, *p, *url_text;
gint len, rc;
* Check for phishing
*/
if ((p = strchr (c, '>')) != NULL ) {
- check_phishing (task, url, p + 1, tag_len - (p - tag_text));
+ check_phishing (task, url, p + 1, remain - (p - tag_text));
}
if (part->html_urls && g_tree_lookup (part->html_urls, url_text) == NULL) {
g_tree_insert (part->html_urls, url_text, url);
gboolean
add_html_node (struct worker_task *task, memory_pool_t * pool, struct mime_text_part *part,
- gchar *tag_text, gsize tag_len, GNode ** cur_level)
+ gchar *tag_text, gsize tag_len, gsize remain, GNode ** cur_level)
{
GNode *new;
struct html_node *data;
part->html_nodes = new;
memory_pool_add_destructor (pool, (pool_destruct_func) g_node_destroy, part->html_nodes);
/* Call once again with root node */
- return add_html_node (task, pool, part, tag_text, tag_len, cur_level);
+ return add_html_node (task, pool, part, tag_text, tag_len, remain, cur_level);
}
else {
new = construct_html_node (pool, tag_text, tag_len);
}
data = new->data;
if (data->tag && (data->tag->id == Tag_A || data->tag->id == Tag_IMG) && ((data->flags & FL_CLOSING) == 0)) {
- parse_tag_url (task, part, data->tag->id, tag_text, tag_len);
+ parse_tag_url (task, part, data->tag->id, tag_text, tag_len, remain);
}
if (data->flags & FL_CLOSING) {
struct worker_task;
gboolean add_html_node (struct worker_task *task, memory_pool_t *pool,
- struct mime_text_part *part, gchar *tag_text, gsize tag_len, GNode **cur_level);
+ struct mime_text_part *part, gchar *tag_text, gsize tag_len, gsize remain, GNode **cur_level);
struct html_tag * get_tag_by_name (const gchar *name);
void decode_entitles (gchar *s, guint *len);
GByteArray *
strip_html_tags (struct worker_task *task, memory_pool_t * pool, struct mime_text_part *part, GByteArray * src, gint *stateptr)
{
- uint8_t *tbuf = NULL, *p, *tp = NULL, *rp, *tbegin = NULL, c, lc;
+ uint8_t *tbuf = NULL, *p, *tp = NULL, *rp, *tbegin = NULL, *end, c, lc;
gint br, i = 0, depth = 0, in_q = 0;
gint state = 0;
GByteArray *buf;
lc = '\0';
p = src->data;
rp = buf->data;
+ end = src->data + src->len;
br = 0;
while (i < src->len) {
case 1: /* HTML/XML */
lc = '>';
in_q = state = 0;
- erase = !add_html_node (task, pool, part, tbegin, p - tbegin, &level_ptr);
+ erase = !add_html_node (task, pool, part, tbegin, p - tbegin, end - tbegin, &level_ptr);
break;
case 2: /* PHP */
end
if newrule['type'] == 'ip' then
newrule['ips'] = rspamd_config:add_radix_map (newrule['map'])
+ if newrule['ips'] then
+ table.insert(rules, newrule)
+ else
+ rspamd_logger.warn('Cannot add rule: map doesn\'t exists: ' .. newrule['map'])
+ end
elseif newrule['type'] == 'header' or newrule['type'] == 'rcpt' or newrule['type'] == 'from' then
newrule['hash'] = rspamd_config:add_hash_map (newrule['map'])
+ if newrule['hash'] then
+ table.insert(rules, newrule)
+ else
+ rspamd_logger.warn('Cannot add rule: map doesn\'t exists: ' .. newrule['map'])
+ end
+ else
+ table.insert(rules, newrule)
end
- table.insert(rules, newrule)
return newrule
end