From b62d83a2661888ea58ce171d8d4b41dbc216e153 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Thu, 11 Jun 2020 21:35:47 +0200
Subject: [PATCH] tests: execute: Add tests for fileinto command executed with
 bad UTF-8 in folder name.

Compile error is avoided by putting the mailbox name in a variable, which is
(currently) only evaluated at runtime.
---
 tests/execute/errors.svtest                  | 17 +++++++++++++++++
 tests/execute/errors/fileinto-bad-utf8.sieve |  7 +++++++
 2 files changed, 24 insertions(+)
 create mode 100644 tests/execute/errors/fileinto-bad-utf8.sieve

diff --git a/tests/execute/errors.svtest b/tests/execute/errors.svtest
index 713180535..45bc39c44 100644
--- a/tests/execute/errors.svtest
+++ b/tests/execute/errors.svtest
@@ -133,3 +133,20 @@ test "Fileinto invalid folder name" {
 	}
 }
 
+test "Fileinto bad UTF-8 in folder name" {
+	if not test_script_compile "errors/fileinto-bad-utf8.sieve" {
+		test_fail "compile failed";
+	}
+
+	if test_script_run {
+		test_fail "execution should have failed";
+	}
+
+	if not test_error :count "eq" :comparator "i;ascii-numeric" "1" {
+		test_fail "wrong number of runtime errors reported";
+	}
+
+	if not test_error :index 1 :contains "invalid folder name" {
+		test_fail "unexpected error reported";
+	}
+}
diff --git a/tests/execute/errors/fileinto-bad-utf8.sieve b/tests/execute/errors/fileinto-bad-utf8.sieve
new file mode 100644
index 000000000..3e57c9224
--- /dev/null
+++ b/tests/execute/errors/fileinto-bad-utf8.sieve
@@ -0,0 +1,7 @@
+require "fileinto";
+require "variables";
+require "encoded-character";
+
+set "mailbox" "${hex:ff}rop";
+fileinto "${mailbox}";
+
-- 
GitLab