Index: clangd/URI.cpp =================================================================== --- clangd/URI.cpp +++ clangd/URI.cpp @@ -91,6 +91,8 @@ case '.': case '~': case '/': // '/' is only reserved when parsing. + // ':' is only reserved for relative URI paths, which clangd doesn't produce. + case ':': return false; } return true; @@ -105,7 +107,7 @@ llvm::raw_string_ostream OS(Result); for (unsigned char C : Content) if (shouldEscape(C)) - OS << '%' << llvm::format_hex_no_prefix(C, 2); + OS << '%' << llvm::format_hex_no_prefix(C, 2, /*Upper = */true); else OS << C; Index: unittests/clangd/URITests.cpp =================================================================== --- unittests/clangd/URITests.cpp +++ unittests/clangd/URITests.cpp @@ -44,8 +44,9 @@ TEST(PercentEncodingTest, Encode) { EXPECT_EQ(URI("x", /*Authority=*/"", "a/b/c").toString(), "x:a/b/c"); - EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3bc~"); + EXPECT_EQ(URI("x", /*Authority=*/"", "a!b;c~").toString(), "x:a%21b%3Bc~"); EXPECT_EQ(URI("x", /*Authority=*/"", "a123b").toString(), "x:a123b"); + EXPECT_EQ(URI("x", /*Authority=*/"", "a:b;c").toString(), "x:a:b%3Bc"); } TEST(PercentEncodingTest, Decode) { @@ -56,6 +57,7 @@ EXPECT_EQ(parseOrDie("s%2b://%3a/%3").body(), "/%3"); EXPECT_EQ(parseOrDie("x:a%21b%3ac~").body(), "a!b:c~"); + EXPECT_EQ(parseOrDie("x:a:b%3bc").body(), "a:b;c"); } std::string resolveOrDie(const URI &U, llvm::StringRef HintPath = "") { @@ -67,10 +69,10 @@ TEST(URITest, Create) { #ifdef _WIN32 - EXPECT_THAT(createOrDie("c:\\x\\y\\z"), "file:///c%3a/x/y/z"); + EXPECT_THAT(createOrDie("c:\\x\\y\\z"), "file:///c:/x/y/z"); #else EXPECT_THAT(createOrDie("/x/y/z"), "file:///x/y/z"); - EXPECT_THAT(createOrDie("/(x)/y/\\ z"), "file:///%28x%29/y/%5c%20z"); + EXPECT_THAT(createOrDie("/(x)/y/\\ z"), "file:///%28x%29/y/%5C%20z"); #endif } @@ -138,6 +140,7 @@ TEST(URITest, Resolve) { #ifdef _WIN32 EXPECT_THAT(resolveOrDie(parseOrDie("file:///c%3a/x/y/z")), "c:\\x\\y\\z"); + EXPECT_THAT(resolveOrDie(parseOrDie("file:///c:/x/y/z")), "c:\\x\\y\\z"); #else EXPECT_EQ(resolveOrDie(parseOrDie("file:/a/b/c")), "/a/b/c"); EXPECT_EQ(resolveOrDie(parseOrDie("file://auth/a/b/c")), "/a/b/c");