diff --git a/src/esp/io/Io.cpp b/src/esp/io/Io.cpp index 45b4e8fd51..f37baf8f11 100644 --- a/src/esp/io/Io.cpp +++ b/src/esp/io/Io.cpp @@ -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 globDirs(const std::string& pattern) { diff --git a/src/tests/IOTest.cpp b/src/tests/IOTest.cpp index 6b7a21c46d..0cdd4d3e08 100644 --- a/src/tests/IOTest.cpp +++ b/src/tests/IOTest.cpp @@ -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); @@ -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);