Skip to content

Commit f45da75

Browse files
Tom94wjakob
authored andcommitted
Handle sporadic usage of "\\" for single-segment relative paths
1 parent 54890b6 commit f45da75

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

filesystem/path.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,20 @@ class path {
239239
tmp.erase(0, LONG_PATH_PREFIX.length());
240240
}
241241

242-
// Special-case handling of absolute SMB paths, which start with the prefix "\\"
242+
// Special-case handling of absolute SMB paths, which start with the prefix "\\".
243243
if (tmp.length() >= 2 && tmp[0] == '\\' && tmp[1] == '\\') {
244244
m_path = {};
245245
tmp.erase(0, 2);
246-
m_absolute = true;
247-
m_smb = true;
246+
247+
// Interestingly, there is a special-special case where relative paths may be specified as beginning with a "\\"
248+
// when a non-SMB file with a more-than-260-characters-long absolute _local_ path is double-clicked. This seems to
249+
// only happen with single-segment relative paths, so we can check for this condition by making sure no further
250+
// path separators are present.
251+
if (tmp.find_first_of("/\\") != std::string::npos)
252+
m_absolute = m_smb = true;
253+
else
254+
m_absolute = m_smb = false;
255+
248256
// Special-case handling of absolute SMB paths, which start with the prefix "UNC\"
249257
} else if (tmp.length() >= 4 && tmp[0] == 'U' && tmp[1] == 'N' && tmp[2] == 'C' && tmp[3] == '\\') {
250258
m_path = {};

0 commit comments

Comments
 (0)