]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-escape: Add tests for escaping bogus UTF-8 sequences
authormsizanoen1 <msizanoen@qtmlabs.xyz>
Wed, 1 Mar 2023 14:48:08 +0000 (21:48 +0700)
committermsizanoen1 <msizanoen@qtmlabs.xyz>
Thu, 2 Mar 2023 12:55:47 +0000 (19:55 +0700)
src/test/test-escape.c

index b1ab5bab188136f9efd14c535b6652b99f5b26d4..f3dd579e56d4813e547d678eae3101045dfd3fc2 100644 (file)
@@ -196,6 +196,10 @@ TEST(shell_maybe_quote) {
 
         test_shell_maybe_quote_one("głąb\002\003rząd", 0, "\"głąb\\002\\003rząd\"");
         test_shell_maybe_quote_one("głąb\002\003rząd", SHELL_ESCAPE_POSIX, "$'głąb\\002\\003rząd'");
+
+        /* Bogus UTF-8 strings */
+        test_shell_maybe_quote_one("\250\350", 0, "\"\\250\\350\"");
+        test_shell_maybe_quote_one("\250\350", SHELL_ESCAPE_POSIX, "$'\\250\\350'");
 }
 
 static void test_quote_command_line_one(char **argv, const char *expected) {