src/platform/path.cpp:77 strips one leading separator from the component so that a component written as /name joins rather than replaces:
if (component.substr(0, 1) == path::separator()) {
p.append(std::string(component).replace(0, 1, ""));
} else {
p.append(component);
}
One character is not always enough. For a component with two leading slashes, stripping one leaves a string that is still absolute, and std::filesystem::path::append replaces the whole path instead of joining:
append("c") on "/a/b" -> "/a/b/c"
append("/c") on "/a/b" -> "/a/b/c"
append("//c") on "/a/b" -> "/c"
append("//server/share") on "/a/b" -> "/server/share"
Measured on Linux with GCC 13.3.0, so this is reachable today and not specific to any one platform. Stripping every leading separator, rather than one, closes it.
A related case exists only if Windows support is implemented: separator() returns "/" unconditionally, so a component starting with \ never matches the guard, and append treats it as root-relative on Windows. Whether that matters depends on #33.
src/platform/path.cpp:77strips one leading separator from the component so that a component written as/namejoins rather than replaces:One character is not always enough. For a component with two leading slashes, stripping one leaves a string that is still absolute, and
std::filesystem::path::appendreplaces the whole path instead of joining:Measured on Linux with GCC 13.3.0, so this is reachable today and not specific to any one platform. Stripping every leading separator, rather than one, closes it.
A related case exists only if Windows support is implemented:
separator()returns"/"unconditionally, so a component starting with\never matches the guard, andappendtreats it as root-relative on Windows. Whether that matters depends on #33.