diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-10-21 10:52:44 +0100 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2017-10-21 21:03:21 +0200 |
commit | ebd597a3dad9e5863ee15d17b1a555eeaaa0276d (patch) | |
tree | 9eadc9775780ffab19897ac2d80cbd9dfe3bbe54 /src | |
parent | 458aad596e12f0dd95c2442a8dc6bbd61922bab6 (diff) | |
download | rspamd-ebd597a3dad9e5863ee15d17b1a555eeaaa0276d.tar.gz rspamd-ebd597a3dad9e5863ee15d17b1a555eeaaa0276d.zip |
[Fix] Fix another tokenization issue
MFH: rspamd-1.6
Diffstat (limited to 'src')
-rw-r--r-- | src/libstat/tokenizers/tokenizers.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/libstat/tokenizers/tokenizers.c b/src/libstat/tokenizers/tokenizers.c index 74c4f5460..c4f814fce 100644 --- a/src/libstat/tokenizers/tokenizers.c +++ b/src/libstat/tokenizers/tokenizers.c @@ -269,15 +269,45 @@ set_token: return TRUE; process_exception: + if (token->len == 0 && processed > 0) { + token->len = p - token->begin; + g_assert (token->len > 0); + } + if (ex->type == RSPAMD_EXCEPTION_URL) { token->begin = "!!EX!!"; token->len = sizeof ("!!EX!!") - 1; token->flags = RSPAMD_STAT_TOKEN_FLAG_EXCEPTION; processed = token->len; } - *cur = p + ex->len; + + p += ex->len; + + /* We need to skip all exceptions that are within this exception */ *exceptions = g_list_next (*exceptions); + while (*exceptions) { + ex = (*exceptions)->data; + + if (ex->pos < p - buf->begin) { + /* Nested exception */ + if (ex->pos + ex->len > p - buf->begin) { + /* + * We have somehow overlapping nesting exception, + * extend current offset + */ + p = buf->begin + ex->pos + ex->len; + } + + *exceptions = g_list_next (*exceptions); + } + else { + break; + } + } + + *cur = p; + if (rl) { *rl = processed; } |