Created
November 25, 2014 00:23
-
-
Save rui314/2a3b97720812aff656ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/util.cc b/src/util.cc | |
index 746d7ed..3a3c7df 100644 | |
--- a/src/util.cc | |
+++ b/src/util.cc | |
@@ -190,6 +190,9 @@ bool CanonicalizePath(char* path, size_t* len, unsigned int* slash_bits, | |
bits_offset--; | |
bits = ShiftOverBit(bits_offset, bits); | |
#endif | |
+ } else if (*start == '/') { | |
+ src += 3; | |
+ dst = start + 1; | |
} else { | |
*dst++ = *src++; | |
*dst++ = *src++; | |
diff --git a/src/util_test.cc b/src/util_test.cc | |
index 8ca7f56..0ce1169 100644 | |
--- a/src/util_test.cc | |
+++ b/src/util_test.cc | |
@@ -80,6 +80,10 @@ TEST(CanonicalizePath, PathSamples) { | |
EXPECT_TRUE(CanonicalizePath(&path, &err)); | |
EXPECT_EQ("/foo", path); | |
+ path = "/../foo"; | |
+ EXPECT_TRUE(CanonicalizePath(&path, &err)); | |
+ EXPECT_EQ("/foo", path); | |
+ | |
path = "//foo"; | |
EXPECT_TRUE(CanonicalizePath(&path, &err)); | |
#ifdef _WIN32 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment