Split from https://gitlab.winehq.org/wine/wine/-/merge_requests/23
-- v3: shell32/tests: Add tests for Program Manager name sanitization.
From: Alex Henrie alexhenrie24@gmail.com
Signed-off-by: Alex Henrie alexhenrie24@gmail.com --- dlls/shell32/tests/progman_dde.c | 72 +++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-)
diff --git a/dlls/shell32/tests/progman_dde.c b/dlls/shell32/tests/progman_dde.c index 5d532f9222f..1b2133a0169 100644 --- a/dlls/shell32/tests/progman_dde.c +++ b/dlls/shell32/tests/progman_dde.c @@ -23,7 +23,7 @@ * functionality * - Todo: Handle CommonGroupFlag * Better AddItem Tests (Lots of parameters to test) - * Tests for Invalid Characters in Names / Invalid Parameters + * Tests for invalid parameters */
#include <stdio.h> @@ -425,6 +425,75 @@ static void test_request_groups(DWORD instance, HCONV hconv) FindClose(hfind); }
+static void test_name_sanitization(DWORD instance, HCONV hConv) +{ + static const char original_name[] = "\x01\x1F !#$%&'*+,-./:;<=>?@[\]^`{|}~\x7F\xFF"; + static const char sanitized_name[] = "__ !#$%&'_+,-.__;_=__@[_]^`{_}~\x7F\xFF"; + char buf[64]; + UINT error; + + if (0) /* the directory isn't deleted on windows < 7 */ + { + error = dde_execute(instance, hConv, "[CreateGroup(" ")]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + ok(check_exists(" "), "directory not created\n"); + ok(!check_window_exists(" "), "window should not exist\n"); + + error = dde_execute(instance, hConv, "[DeleteGroup(" ")]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + ok(!check_exists(" "), "directory should not exist\n"); + } + + if (0) /* these calls will actually delete the start menu */ + { + error = dde_execute(instance, hConv, "[DeleteGroup("")]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + ok(!check_exists("../Programs"), "directory should not exist\n"); + + error = dde_execute(instance, hConv, "[DeleteGroup("..")]"); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + ok(!check_exists("../../Start Menu"), "directory should not exist\n"); + } + + sprintf(buf, "[CreateGroup("Group%s")]", original_name); + error = dde_execute(instance, hConv, buf); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + sprintf(buf, "Group%s", sanitized_name); + todo_wine ok(check_exists(buf), "directory not created\n"); + if (!check_exists(buf)) return; + ok(check_window_exists(buf), "window not created\n"); + + sprintf(buf, "[ShowGroup("Group%s", 0)]", original_name); + error = dde_execute(instance, hConv, buf); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + sprintf(buf, "Group%s", sanitized_name); + ok(check_window_exists(buf), "window not created\n"); + + sprintf(buf, "[AddItem(notepad,"Notepad%s")]", original_name); + error = dde_execute(instance, hConv, buf); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + sprintf(buf, "Group%s/Notepad%s.lnk", sanitized_name, sanitized_name); + ok(check_exists(buf), "link not created\n"); + + sprintf(buf, "[ReplaceItem("Notepad%s")]", original_name); + error = dde_execute(instance, hConv, buf); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %#x\n", error); + sprintf(buf, "Group%s/Notepad%s.lnk", sanitized_name, sanitized_name); + ok(check_exists(buf), "link should still exist\n"); + + sprintf(buf, "[DeleteItem("Notepad%s")]", original_name); + error = dde_execute(instance, hConv, buf); + ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %#x\n", error); + sprintf(buf, "Group%s/Notepad%s.lnk", sanitized_name, sanitized_name); + ok(check_exists(buf), "link should still exist\n"); + + sprintf(buf, "[DeleteGroup("Group%s")]", original_name); + error = dde_execute(instance, hConv, buf); + ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %#x\n", error); + sprintf(buf, "Group%s", sanitized_name); + ok(!check_exists(buf), "directory should not exist\n"); +} + START_TEST(progman_dde) { DWORD instance = 0; @@ -479,6 +548,7 @@ START_TEST(progman_dde)
/* Run Tests */ test_progman_dde2(instance, hConv); + test_name_sanitization(instance, hConv);
/* Cleanup & Exit */ ret = DdeDisconnect(hConv);
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=117192
Your paranoid android.
=== w864 (64 bit report) ===
shell32: 0be8:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w1064v1507 (64 bit report) ===
shell32: 0e98:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w1064v1809 (64 bit report) ===
shell32: 1f08:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w1064 (64 bit report) ===
shell32: 1c64:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w1064_2qxl (64 bit report) ===
shell32: 1f64:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w1064_adm (64 bit report) ===
shell32: 1d64:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w1064_tsign (64 bit report) ===
shell32: 1054:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w10pro64 (64 bit report) ===
shell32: 1e2c:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w10pro64_en_AE_u8 (64 bit report) ===
shell32: 19dc:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w10pro64_ar (64 bit report) ===
shell32: 1b0c:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w10pro64_ja (64 bit report) ===
shell32: 1fb8:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== w10pro64_zh_CN (64 bit report) ===
shell32: 2344:progman_dde: unhandled exception c0000005 at 000000000046DAB6
=== debian11 (32 bit Japanese:Japan report) ===
shell32: progman_dde.c:259: Test failed: expected DMLERR_NO_ERROR, got 16393 progman_dde.c:260: Test failed: directory should not exist
I have replaced the loop with one big test for all of the interesting characters. The test time now remains at 5 seconds.