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

Testsuite: added lexer string scan comparison test and fixed lexer bug in the process.

parent 6e9716f2
No related branches found
No related tags found
No related merge requests found
...@@ -565,21 +565,33 @@ static bool sieve_lexer_scan_raw_token(struct sieve_lexer *lexer) ...@@ -565,21 +565,33 @@ static bool sieve_lexer_scan_raw_token(struct sieve_lexer *lexer)
/* Parse literal lines */ /* Parse literal lines */
while ( TRUE ) { while ( TRUE ) {
bool cr_shifted = FALSE;
/* Remove dot-stuffing or detect end of text */ /* Remove dot-stuffing or detect end of text */
if ( sieve_lexer_curchar(lexer) == '.' ) { if ( sieve_lexer_curchar(lexer) == '.' ) {
bool cr_shifted = FALSE;
sieve_lexer_shift(lexer); sieve_lexer_shift(lexer);
/* Check for CRLF */ /* Check for CRLF */
if ( sieve_lexer_curchar(lexer) == '\r' ) if ( sieve_lexer_curchar(lexer) == '\r' ) {
sieve_lexer_shift(lexer); sieve_lexer_shift(lexer);
cr_shifted = TRUE;
}
if ( sieve_lexer_curchar(lexer) == '\n' ) { if ( sieve_lexer_curchar(lexer) == '\n' ) {
sieve_lexer_shift(lexer); sieve_lexer_shift(lexer);
lexer->token_type = STT_STRING; lexer->token_type = STT_STRING;
return TRUE; return TRUE;
} else if ( cr_shifted ) } else if ( cr_shifted ) {
str_append_c(str, '\r'); sieve_lexer_error(lexer,
"found CR without subsequent LF in multi-line string literal");
lexer->token_type = STT_ERROR;
return FALSE;
}
/* Handle dot-stuffing */
str_append_c(str, '.');
if ( sieve_lexer_curchar(lexer) == '.' )
sieve_lexer_shift(lexer);
} }
/* Scan the rest of the line */ /* Scan the rest of the line */
......
...@@ -65,6 +65,7 @@ test_cases = \ ...@@ -65,6 +65,7 @@ test_cases = \
tests/testsuite.svtest\ tests/testsuite.svtest\
tests/control-structures.svtest \ tests/control-structures.svtest \
tests/exists.svtest \ tests/exists.svtest \
tests/lexer.svtest \
tests/comparators/core.svtest \ tests/comparators/core.svtest \
tests/match-types/contains.svtest \ tests/match-types/contains.svtest \
tests/match-types/matches.svtest \ tests/match-types/matches.svtest \
......
require "vnd.dovecot.testsuite";
require "variables";
/* Test conformance to RFC 5228 - 2.4.2. Strings */
set "text" text:
Line 1
.Line 2
..Line 3
.Line 4
Line 5
.
;
set "quoted"
"Line 1
.Line 2
.Line 3
.Line 4
Line 5
";
test "LEXER-string-literal" {
if not string :is "${text}" "${quoted}" {
test_fail "lexer messed-up dot stuffing";
}
}
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.