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

Fixed bugs in :matches implementation.

parent 2761af1e
No related branches found
No related tags found
No related merge requests found
......@@ -37,36 +37,36 @@ if header :matches "x-bullshit" "*3333\\?\\?\\?a" {
fileinto "SHOULD NOT MATCH";
if address :matches "from" "*@d*kn*ers.com" {
fileinto "A";
fileinto "NA";
}
if address :matches "from" "stepan+sieve@drunksnipers.*" {
fileinto "B";
fileinto "NB";
}
if address :matches "from" "*+sieve@drunksnipers.om" {
fileinto "C";
fileinto "NC";
}
if address :matches "from" "stephan+sieve?drunksipers.com" {
fileinto "D";
fileinto "ND";
}
if address :matches "from" "?tephan+sievedrunksnipers.com" {
fileinto "E";
fileinto "NE";
}
if address :matches "from" "sephan+sieve@drunksnipers.co?" {
fileinto "F";
fileinto "NF";
}
if address :matches "from" "?t?phan?sieve?dunksnip?rs.co?" {
fileinto "G";
fileinto "NG";
}
if header :matches "x-bullshit" "33333\\?\\?\\?" {
fileinto "H";
fileinto "NH";
}
if header :matches "x-bullshit" "33333\\?\\?\\?aa" {
fileinto "I";
fileinto "NI";
}
if header :matches "x-bullshit" "\\*3333\\?\\?\\?a" {
fileinto "J";
fileinto "NJ";
}
if header :matches "x-bullshit" "\\f3333\\?\\?\\?a" {
fileinto "J";
fileinto "NK";
}
......@@ -38,7 +38,7 @@ const struct sieve_match_type matches_match_type = {
*/
/* Quick 'n dirty debug */
//#define MATCH_DEBUG
#define MATCH_DEBUG
#ifdef MATCH_DEBUG
#define debug_printf(...) printf (__VA_ARGS__)
#else
......@@ -225,7 +225,6 @@ static bool mcht_matches_match
str_append_n(mvalue, pvp, qp-pvp);
for ( ; qp < qend; qp++ )
str_append_c(mchars, *qp);
//sieve_match_values_add_char(mvalues, *qp);
debug_printf("MATCH :: %s\n", str_c(mvalue));
}
......@@ -249,7 +248,8 @@ static bool mcht_matches_match
debug_printf("MATCH fkey: '%s'\n", t_strdup_until(needle, nend));
debug_printf("MATCH fval: '%s'\n", t_strdup_until(vp, vend));
if ( !cmp->char_match(cmp, &vp, vend, &needle, nend) ) {
if ( (needle == nend && vp < vend ) ||
!cmp->char_match(cmp, &vp, vend, &needle, nend) ) {
if ( prv != NULL && prv + 1 < vend ) {
vp = prv;
kp = prk;
......@@ -262,7 +262,12 @@ static bool mcht_matches_match
next_wcard = '?';
backtrack = TRUE;
debug_printf("MATCH backtrack\n");
} else {
/* We are sure to have failed */
return FALSE;
}
debug_printf("MATCH failed fixed\n");
break;
}
......
......@@ -213,11 +213,15 @@ static bool tst_header_operation_execute
while ( !matched && (result=sieve_coded_stringlist_next_item(hdr_list, &hdr_item))
&& hdr_item != NULL ) {
const char *const *headers;
printf("HEADER: %s\n", str_c(hdr_item));
if ( mail_get_headers_utf8(renv->msgdata->mail, str_c(hdr_item), &headers) >= 0 ) {
int i;
for ( i = 0; !matched && headers[i] != NULL; i++ ) {
printf("HEADER: %s %s\n", str_c(hdr_item), headers[i]);
if ( sieve_match_value(mctx, headers[i], strlen(headers[i])) )
matched = TRUE;
}
......
......@@ -71,7 +71,7 @@ test "MATCH-I" {
}
test "MATCH-J" {
if not header :matches "x-bullshit" "*\\?\\?\\?a" {
if not header :matches "X-Bullshit" "*\\?\\?\\?a" {
test_fail "J case should have matched";
}
}
......
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.