Skip to content
Snippets Groups Projects
Commit be698fd0 authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Enotify: implemented :encodeurl variables modifier.

parent 3d3aa53e
No related branches found
No related tags found
No related merge requests found
...@@ -23,6 +23,7 @@ endif ...@@ -23,6 +23,7 @@ endif
if BUILD_ENOTIFY if BUILD_ENOTIFY
ENOTIFY_TESTS = \ ENOTIFY_TESTS = \
tests/extensions/enotify/basic.svtest \ tests/extensions/enotify/basic.svtest \
tests/extensions/enotify/encodeurl.svtest \
tests/extensions/enotify/execute.svtest tests/extensions/enotify/execute.svtest
endif endif
......
This diff is collapsed.
...@@ -42,14 +42,41 @@ const struct sieve_operand encodeurl_operand = { ...@@ -42,14 +42,41 @@ const struct sieve_operand encodeurl_operand = {
* Modifier implementation * Modifier implementation
*/ */
static const char uri_reserved_lookup[256] = { static const char _uri_reserved_lookup[256] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 00
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 10
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, // 20
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, // 30
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 40
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, // 50
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 60
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, // 70
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 80
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 90
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // A0
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // B0
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // C0
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // D0
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // E0
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // F0
}; };
bool mod_encodeurl_modify(string_t *in, string_t **result) bool mod_encodeurl_modify(string_t *in, string_t **result)
{ {
unsigned int i;
const unsigned char *c;
*result = t_str_new(2*str_len(in)); *result = t_str_new(2*str_len(in));
c = str_data(in);
for ( i = 0; i < str_len(in); i++, c++ ) {
if ( _uri_reserved_lookup[*c] ) {
str_printfa(*result, "%%%02X", *c);
} else {
str_append_c(*result, *c);
}
}
return TRUE; return TRUE;
} }
......
require "vnd.dovecot.testsuite";
require "variables";
require "enotify";
test "Encode Simple" {
set :encodeurl "url_data" "\\frop\\&fruts/^@";
if not string :is :comparator "i;octet" "${url_data}" "%5Cfrop%5C%26fruts%2F%5E%40" {
test_fail "url data encoded incorrectly '${url_data}'";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.