Skip to content

Commit

Permalink
Fix issue #1923: Save function doesn't work if the path length exceed…
Browse files Browse the repository at this point in the history
…s 248 characters
  • Loading branch information
sdottaka committed Jun 30, 2023
1 parent 0c719bf commit 3c2e135
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Src/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,10 +738,20 @@ String GetPathOnly(const String& fullpath)
return spath;
}

bool IsURL(const String& path)
bool IsURL(const String& abspath)
{
size_t pos = path.find(':');
return (pos != String::npos && pos > 1);
for (size_t i = 0; i < abspath.length(); ++i)
{
const auto c = abspath[i];
if (c == '\\' || c == '/')
{
// If there is a \ or / before the : character, consider it not a URL.
return false;
}
else if (c == ':')
return (i != 1);
}
return false;
}

bool IsURLorCLSID(const String& path)
Expand Down
8 changes: 8 additions & 0 deletions Testing/GoogleTest/Paths/paths_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,12 @@ namespace
EXPECT_FALSE(paths::IsPathAbsolute(_T("cde\\abd")));
}

TEST_F(PathTest, IsURL)
{
EXPECT_FALSE(paths::IsURL(_T("C:\\file.txt")));
EXPECT_FALSE(paths::IsURL(_T("\\\\?\\C:\\file.txt")));
EXPECT_FALSE(paths::IsURL(_T("\\\\server\\file.txt")));
EXPECT_TRUE(paths::IsURL(_T("https://server/")));
}

} // namespace

0 comments on commit 3c2e135

Please sign in to comment.