aboutsummaryrefslogtreecommitdiffstats
path: root/src/libstat
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-13 17:03:27 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-13 17:07:23 +0100
commit70cbb6d39a06eb6f71832517bfd788ad217b6965 (patch)
tree5e0e41033565b271021072aa5c2455f0e79a91a7 /src/libstat
parentd2af2a1d52a8f9b26b7c77b12ce555db24f07df4 (diff)
downloadrspamd-70cbb6d39a06eb6f71832517bfd788ad217b6965.tar.gz
rspamd-70cbb6d39a06eb6f71832517bfd788ad217b6965.zip
[Rework] Rework exceptions and newlines processing
Diffstat (limited to 'src/libstat')
-rw-r--r--src/libstat/tokenizers/tokenizers.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/libstat/tokenizers/tokenizers.c b/src/libstat/tokenizers/tokenizers.c
index 4e0e4b75d..6eab11f98 100644
--- a/src/libstat/tokenizers/tokenizers.c
+++ b/src/libstat/tokenizers/tokenizers.c
@@ -75,7 +75,7 @@ rspamd_tokenizer_get_word_compat (rspamd_ftok_t * buf,
{
gsize remain, pos;
const gchar *p;
- struct process_exception *ex = NULL;
+ struct rspamd_process_exception *ex = NULL;
if (buf == NULL) {
return FALSE;
@@ -166,11 +166,12 @@ rspamd_tokenizer_get_word (rspamd_ftok_t * buf,
GList **exceptions, gboolean is_utf, gsize *rl,
gboolean check_signature)
{
- gsize remain, pos, siglen = 0;
+ gsize remain, siglen = 0;
+ goffset pos;
const gchar *p, *next_p, *sig = NULL;
gunichar uc;
guint processed = 0;
- struct process_exception *ex = NULL;
+ struct rspamd_process_exception *ex = NULL;
enum {
skip_delimiters = 0,
feed_token,
@@ -214,10 +215,12 @@ rspamd_tokenizer_get_word (rspamd_ftok_t * buf,
switch (state) {
case skip_delimiters:
- if (ex != NULL && p - buf->begin == (gint)ex->pos) {
- token->begin = "!!EX!!";
- token->len = sizeof ("!!EX!!") - 1;
- processed = token->len;
+ if (ex != NULL && p - buf->begin == ex->pos) {
+ if (ex->type == RSPAMD_EXCEPTION_URL) {
+ token->begin = "!!EX!!";
+ token->len = sizeof ("!!EX!!") - 1;
+ processed = token->len;
+ }
state = skip_exception;
continue;
}
@@ -270,12 +273,13 @@ set_token:
*rl = processed;
}
- if (token->len == 0) {
+ if (token->len == 0 && processed > 0) {
token->len = p - token->begin;
g_assert (token->len > 0);
- *cur = p;
}
+ *cur = p;
+
return TRUE;
}