Commit c27b2461 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

kernelbase: Don't strip leading dots in relative paths.

parent 0da35c26
......@@ -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 \\
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment