diff --git a/TODO b/TODO index d3761e0b58dbc75ced186cfd381f4d8c06d5522b..a72c980dd963e925a9a2eda0b5c31b889830fe5b 100644 --- a/TODO +++ b/TODO @@ -3,7 +3,6 @@ Next (in order of descending priority/precedence): * Full standards compliance review for the engine and all fully implemented sieve extensions. Issues discovered so far: - - Header test does not strip trailing whitespace - Fix/Report issues listed in 'doc/rfc/RFC Controversy.txt' * Code cleanup * Full security review. Enforce limits on number of created objects, script diff --git a/src/lib-sieve/tst-header.c b/src/lib-sieve/tst-header.c index 1fd90807ae5675653fda29bc2d5d8e1951c0afb9..3ca310678b6bd4a358877187f012d5befd42e4c3 100644 --- a/src/lib-sieve/tst-header.c +++ b/src/lib-sieve/tst-header.c @@ -144,6 +144,20 @@ static bool tst_header_operation_dump * Code execution */ +static inline string_t *_header_right_trim(const char *raw) +{ + string_t *result; + int i; + + for ( i = strlen(raw)-1; i >= 0; i-- ) { + if ( raw[i] != ' ' && raw[i] != '\t' ) break; + } + + result = t_str_new(i+1); + str_append_n(result, raw, i + 1); + return result; +} + static int tst_header_operation_execute (const struct sieve_operation *op ATTR_UNUSED, const struct sieve_runtime_env *renv, sieve_size_t *address) @@ -200,7 +214,10 @@ static int tst_header_operation_execute int i; for ( i = 0; !matched && headers[i] != NULL; i++ ) { - if ( (ret=sieve_match_value(mctx, headers[i], strlen(headers[i]))) < 0 ) + string_t *theader = _header_right_trim(headers[i]); + + if ( (ret=sieve_match_value(mctx, str_c(theader), str_len(theader))) + < 0 ) { result = FALSE; break;