Skip to content

Commit

Permalink
--properly handle multiple sequential ellipses (#2219)
Browse files Browse the repository at this point in the history
includes test.
  • Loading branch information
jturner65 authored Sep 28, 2023
1 parent 8f5d58d commit aeabb76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/esp/io/Io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ std::string normalizePath(const std::string& srcPath) {
// Get paths leading up to ellipsis-cancelled path
auto prefixString = srcPath.substr(0, prevLoc);
// recurses to get subsequent ellipses.
auto filteredPath = Cr::Utility::formatString("{}/{}", prefixString,
normalizePath(suffixString));
return filteredPath;
auto filteredPath =
Cr::Utility::formatString("{}/{}", prefixString, suffixString);
return normalizePath(filteredPath);
} // normalizePath

std::vector<std::string> globDirs(const std::string& pattern) {
Expand Down
7 changes: 7 additions & 0 deletions src/tests/IOTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void IOTest::testEllipsisFilter() {
testPath1 = "/test/path/DELETE/../to/test/removal.txt";
res = esp::io::normalizePath(testPath1);
CORRADE_COMPARE(res, "/test/path/to/test/removal.txt");

testPath1 =
"/test/path/DELETE/../to/DELETE/../test/DELETE/../multiple/removal.txt";
res = esp::io::normalizePath(testPath1);
Expand All @@ -122,6 +123,12 @@ void IOTest::testEllipsisFilter() {
res = esp::io::normalizePath(testPath1);
CORRADE_COMPARE(res, "test/path/to/test/multiple/removal.txt");

testPath1 =
"/test/path/DELETE/DELETE2/DELETE3/../../../to/DELETE/DELETE2/../../test/"
"DELETE/../consecutive/removal.txt";
res = esp::io::normalizePath(testPath1);
CORRADE_COMPARE(res, "/test/path/to/test/consecutive/removal.txt");

// ignore intitial ellipsis
testPath1 = "/../test/path/DELETE/../to/test/initial/ignore.txt";
res = esp::io::normalizePath(testPath1);
Expand Down

0 comments on commit aeabb76

Please sign in to comment.