summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util.cc2
-rw-r--r--src/util_test.cc4
2 files changed, 5 insertions, 1 deletions
diff --git a/src/util.cc b/src/util.cc
index 2a43775..7668e33 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -253,7 +253,7 @@ void CanonicalizePath(char* path, size_t* len, uint64_t* slash_bits) {
if (src[0] == '.') {
if (component_len == 1)
break; // Ignore trailing '.' (e.g. 'foo/.' -> 'foo/')
- if (src[1] == '.') {
+ if (component_len == 2 && src[1] == '.') {
// Handle '..'. Back up if possible.
if (component_count > 0) {
while (--dst > dst0 && !IsPathSeparator(dst[-1])) {
diff --git a/src/util_test.cc b/src/util_test.cc
index 8467e2a..d76954c 100644
--- a/src/util_test.cc
+++ b/src/util_test.cc
@@ -152,6 +152,10 @@ TEST(CanonicalizePath, PathSamples) {
path = "foo/..";
CanonicalizePath(&path);
EXPECT_EQ(".", path);
+
+ path = "foo/.._bar";
+ CanonicalizePath(&path);
+ EXPECT_EQ("foo/.._bar", path);
}
#ifdef _WIN32