Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49315 Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/kernelbase/path.c | 2 +- dlls/shlwapi/tests/path.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c index 14e892bcc42..9387705e963 100644 --- a/dlls/kernelbase/path.c +++ b/dlls/kernelbase/path.c @@ -1389,7 +1389,7 @@ BOOL WINAPI PathCanonicalizeW(WCHAR *buffer, const WCHAR *path) { src += 2; /* Skip .\ */ } - else if (src[1] == '.' && (dst == buffer || dst[-1] == '\')) + else if (src[1] == '.' && dst != buffer && dst[-1] == '\') { /* .. backs up a directory, over the root if it has no \ following X:. * .. is ignored if it would remove a UNC server name or initial \ diff --git a/dlls/shlwapi/tests/path.c b/dlls/shlwapi/tests/path.c index e9f08a902b0..dbe1f36fbfd 100644 --- a/dlls/shlwapi/tests/path.c +++ b/dlls/shlwapi/tests/path.c @@ -714,6 +714,15 @@ static void test_PathCombineA(void) ok(!lstrcmpA(str, "C:\"), "Expected C:\, got %s\n", str); ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
+ /* try relative paths */ + /* try forward slashes */ + SetLastError(0xdeadbeef); + lstrcpyA(dest, "control"); + str = PathCombineA(dest, "../../../one/two/", "*"); + ok(str == dest, "Expected str == dest, got %p\n", str); + ok(!lstrcmpA(str, "../../../one/two/\*"), "Expected ../../../one/two/\*, got %s\n", str); + ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); + memset(too_long, 'a', LONG_LEN); too_long[LONG_LEN - 1] = '\0';
@@ -1039,6 +1048,22 @@ static void test_PathCanonicalizeA(void) !lstrcmpA(dest, "C:\one/"), /* Vista */ "Expected "C:\one/." or "C:\one/", got "%s"\n", dest);
+ /* try relative forward slashes */ + lstrcpyA(dest, "test"); + SetLastError(0xdeadbeef); + res = PathCanonicalizeA(dest, "../../one/two/"); + ok(res, "Expected success\n"); + ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); + ok(!lstrcmpA(dest, "../../one/two/"), "Expected ../../one/two/, got %s\n", dest); + + /* try relative forward slashes */ + lstrcpyA(dest, "test"); + SetLastError(0xdeadbeef); + res = PathCanonicalizeA(dest, "../../one/two/\*"); + ok(res, "Expected success\n"); + ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError()); + ok(!lstrcmpA(dest, "../../one/two/\*"), "Expected ../../one/two/\*, got %s\n", dest); + /* try forward slashes with change dirs * NOTE: if there is a forward slash in between two backslashes, * everything in between the two backslashes is considered on dir