[PATCH] D53016: [clangd] Mark colon as a safe character when percent-encoding.
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 9 03:31:43 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL344033: [clangd] Mark colon as a safe character when percent-encoding. (authored by kadircet, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D53016
Files:
clang-tools-extra/trunk/clangd/URI.cpp
clang-tools-extra/trunk/unittests/clangd/URITests.cpp
Index: clang-tools-extra/trunk/unittests/clangd/URITests.cpp
===================================================================
--- clang-tools-extra/trunk/unittests/clangd/URITests.cpp
+++ clang-tools-extra/trunk/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");
Index: clang-tools-extra/trunk/clangd/URI.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/URI.cpp
+++ clang-tools-extra/trunk/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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53016.168772.patch
Type: text/x-patch
Size: 2470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181009/d162c4e3/attachment.bin>
More information about the cfe-commits
mailing list