This commit is contained in:
Igor Pavlov
2015-11-19 00:00:00 +00:00
committed by Kornel Lesiński
parent 7c8a265a15
commit e24f7fba53
70 changed files with 701 additions and 332 deletions

View File

@@ -451,32 +451,42 @@ static UString GetDirPrefixOf(const UString &src)
return s;
}
static bool IsSafePath(const UString &path)
#endif
bool IsSafePath(const UString &path)
{
if (NName::IsAbsolutePath(path))
return false;
UStringVector parts;
SplitPathToParts(path, parts);
int level = 0;
FOR_VECTOR(i, parts)
unsigned level = 0;
FOR_VECTOR (i, parts)
{
const UString &s = parts[i];
if (s.IsEmpty())
{
if (i == 0)
return false;
continue;
}
if (s == L".")
continue;
if (s == L"..")
{
if (level <= 0)
if (level == 0)
return false;
level--;
}
else
level++;
}
return level > 0;
}
#endif
bool CensorNode_CheckPath2(const NWildcard::CCensorNode &node, const CReadArcItem &item, bool &include)
{