Skip to content

Commit 224cd1e

Browse files
committed
GetAbsPath fix for a rel path ending in '.' or '..'
1 parent b66026f commit 224cd1e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

BeefySysLib/Common.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,21 @@ String Beefy::GetAbsPath(const StringImpl& relPathIn, const StringImpl& dir)
12241224

12251225
//newPath = driveString + newPath + tempRelPath;
12261226
newPath = driveString + newPath;
1227-
newPath += relPath.Substring(relIdx);
1227+
1228+
StringView endStr(relPath, relIdx);
1229+
if (endStr == ".")
1230+
{
1231+
// Ignore
1232+
}
1233+
else if (endStr == "..")
1234+
{
1235+
int lastDirStart = (int)newPath.length() - 1;
1236+
while ((lastDirStart > 0) && (newPath[lastDirStart - 1] != '\\') && (newPath[lastDirStart - 1] != '/'))
1237+
lastDirStart--;
1238+
newPath.RemoveToEnd(lastDirStart);
1239+
}
1240+
else
1241+
newPath += endStr;
12281242

12291243
return newPath;
12301244
}

0 commit comments

Comments
 (0)