From e6e7e6c348843be148c428834eb424c439e5e617 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 30 Nov 2016 16:08:45 +0000 Subject: [PATCH] Fix handling of consecutive slashes in FileSpec::GetNormalizedPath() The core of the function was actually handling them correctly. However, the early exit was being too optimistic and did not give the function a chance to fire if the path did not contain dots as well. Fix that and add a couple of unit tests. llvm-svn: 288247 --- lldb/source/Host/common/FileSpec.cpp | 3 ++- lldb/unittests/Host/FileSpecTest.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp index d958d8c..9287336 100644 --- a/lldb/source/Host/common/FileSpec.cpp +++ b/lldb/source/Host/common/FileSpec.cpp @@ -544,7 +544,8 @@ bool FileSpec::Equal(const FileSpec &a, const FileSpec &b, bool full, FileSpec FileSpec::GetNormalizedPath() const { // Fast path. Do nothing if the path is not interesting. if (!m_directory.GetStringRef().contains(".") && - (m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != ".")) + !m_directory.GetStringRef().contains("//") && + m_filename.GetStringRef() != ".." && m_filename.GetStringRef() != ".") return *this; llvm::SmallString<64> path, result; diff --git a/lldb/unittests/Host/FileSpecTest.cpp b/lldb/unittests/Host/FileSpecTest.cpp index 843dcb8..338515d 100644 --- a/lldb/unittests/Host/FileSpecTest.cpp +++ b/lldb/unittests/Host/FileSpecTest.cpp @@ -206,6 +206,9 @@ TEST(FileSpecTest, GetNormalizedPath) { {"/foo/./bar", "/foo/bar"}, {"/foo/..", "/"}, {"/foo/.", "/foo"}, + {"/foo//bar", "/foo/bar"}, + {"/foo//bar/baz", "/foo/bar/baz"}, + {"/foo//bar/./baz", "/foo/bar/baz"}, {"/./foo", "/foo"}, {"/", "/"}, {"//", "//"}, -- 2.7.4