File("/moose/fish").getChildFile("…/…/foo.txt") is expected to produce “/foo.txt”, but actually it returns “/moose/foo.txt”.
This problem seems to occur when it is called with the relative path via root directory and not to occur on Windows.
Here is my fix. Will it cause any side effect?
while (relativePath[0] == T('.'))
{
if (relativePath[1] == T('.'))
{
if (relativePath [2] == 0 || relativePath[2] == separator)
{
const int lastSlash = path.lastIndexOfChar (separator);
// [original code]
// if (lastSlash > 0)
// [/original code]
// [fixed code]
if (lastSlash >= 0)
// [/fixed code]
path = path.substring (0, lastSlash);
relativePath = relativePath.substring (3);
}
else
{
break;
}
}
else if (relativePath[1] == separator)
{
relativePath = relativePath.substring (2);
}
else
{
break;
}
}