diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-11 21:58:32 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-11 21:58:32 +0100 |
commit | 3ff2ccae3db08913bccfc0fd5c0ad98aaffca642 (patch) | |
tree | d323b8b9b4c64fe1d8decbefe9ef43abe48e0a82 | |
parent | c24c45386f95fe1f8fd0f68c1734d292c63b9969 (diff) | |
download | rspamd-3ff2ccae3db08913bccfc0fd5c0ad98aaffca642.tar.gz rspamd-3ff2ccae3db08913bccfc0fd5c0ad98aaffca642.zip |
Allow query parameters for files.
-rw-r--r-- | src/libserver/protocol.c | 25 | ||||
-rw-r--r-- | test/functional/cases/scan_file.sh | 6 |
2 files changed, 30 insertions, 1 deletions
diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index f9b2f0f3b..761b04a30 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -252,7 +252,30 @@ rspamd_protocol_handle_url (struct rspamd_task *task, /* In case if we have a query, we need to store it somewhere */ task->msg.start = msg->url->str + u.field_data[UF_QUERY].off; task->msg.len = u.field_data[UF_QUERY].len; - task->flags |= RSPAMD_TASK_FLAG_FILE; + + /* Check URL query parameters */ + p = memchr (task->msg.start, '=', task->msg.len); + + if (p != NULL) { + if (p != task->msg.start && + (memcmp (task->msg.start, "file", + (p - task->msg.start)) == 0 || + memcmp (task->msg.start, "path", + (p - task->msg.start)) == 0)) { + task->flags |= RSPAMD_TASK_FLAG_FILE; + task->msg.start = p + 1; + task->msg.len -= (p - task->msg.start) + 1; + task->flags |= RSPAMD_TASK_FLAG_FILE; + } + else { + msg_err ("invalid query parameter: %*s", task->msg.len, + task->msg.start); + } + } + else { + /* Just file url afterwards */ + task->flags |= RSPAMD_TASK_FLAG_FILE; + } } return TRUE; diff --git a/test/functional/cases/scan_file.sh b/test/functional/cases/scan_file.sh index b4ec293b4..63626cae6 100644 --- a/test/functional/cases/scan_file.sh +++ b/test/functional/cases/scan_file.sh @@ -5,4 +5,10 @@ export RSPAMD_CONFIG="$TEST_DIRNAME/configs/trivial.conf" run_rspamd run perl "$TEST_DIRNAME/cases/scan_file.pl" "$TEST_DIRNAME/messages/gtube.eml" +check_output 'GTUBE' + +run perl "$TEST_DIRNAME/cases/scan_file.pl" "file=$TEST_DIRNAME/messages/gtube.eml" +check_output 'GTUBE' + +run perl "$TEST_DIRNAME/cases/scan_file.pl" "path=$TEST_DIRNAME/messages/gtube.eml" check_output 'GTUBE'
\ No newline at end of file |