Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/protocol/Verify.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,25 @@ VerifyPathUTF8(std::string_view path_utf8) noexcept
bool
VerifyRelativePathUTF8(std::string_view path_utf8) noexcept
{
// TODO check whether it's a relative path
return VerifyPathUTF8(path_utf8);
if (!VerifyPathUTF8(path_utf8) || path_utf8.front() == '/')
return false;

while (!path_utf8.empty()) {
auto slash = path_utf8.find('/');
auto component = slash == path_utf8.npos
? path_utf8
: path_utf8.substr(0, slash);

if (component.empty() || component == "." || component == "..")
return false;

if (slash == path_utf8.npos)
break;

path_utf8.remove_prefix(slash + 1);
}

return true;
}

bool
Expand Down
Loading