diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-10-21 10:52:44 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-10-21 10:52:44 +0100 |
commit | 2330df2d216719a3a0cadda55b4ff1ccf7dafe5a (patch) | |
tree | c7a891d4533391be40ea86d634746dc90b91e083 /src/libstat | |
parent | 2b7f12aa512b58b450164289d773a335741cee81 (diff) | |
download | rspamd-2330df2d216719a3a0cadda55b4ff1ccf7dafe5a.tar.gz rspamd-2330df2d216719a3a0cadda55b4ff1ccf7dafe5a.zip |
[Fix] Fix another tokenization issue
MFH: rspamd-1.6
Diffstat (limited to 'src/libstat')
-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; } |