[Lldb-commits] [PATCH] D59779: [Args] Handle backticks
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Mar 25 10:27:10 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rLLDB356927: [Args] Handle backticks to prevent crash. (authored by JDevlieghere, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D59779?vs=192131&id=192139#toc
Repository:
rLLDB LLDB
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59779/new/
https://reviews.llvm.org/D59779
Files:
source/Utility/Args.cpp
unittests/Utility/ArgsTest.cpp
Index: unittests/Utility/ArgsTest.cpp
===================================================================
--- unittests/Utility/ArgsTest.cpp
+++ unittests/Utility/ArgsTest.cpp
@@ -188,3 +188,29 @@
EXPECT_STREQ("foo", ref[0]);
EXPECT_STREQ("bar", ref[1]);
}
+
+TEST(ArgsTest, EscapeLLDBCommandArgument) {
+ const std::string foo = "foo'";
+ EXPECT_EQ("foo\\'", Args::EscapeLLDBCommandArgument(foo, '\0'));
+ EXPECT_EQ("foo'", Args::EscapeLLDBCommandArgument(foo, '\''));
+ EXPECT_EQ("foo'", Args::EscapeLLDBCommandArgument(foo, '`'));
+ EXPECT_EQ("foo'", Args::EscapeLLDBCommandArgument(foo, '"'));
+
+ const std::string bar = "bar\"";
+ EXPECT_EQ("bar\\\"", Args::EscapeLLDBCommandArgument(bar, '\0'));
+ EXPECT_EQ("bar\"", Args::EscapeLLDBCommandArgument(bar, '\''));
+ EXPECT_EQ("bar\"", Args::EscapeLLDBCommandArgument(bar, '`'));
+ EXPECT_EQ("bar\\\"", Args::EscapeLLDBCommandArgument(bar, '"'));
+
+ const std::string baz = "baz`";
+ EXPECT_EQ("baz\\`", Args::EscapeLLDBCommandArgument(baz, '\0'));
+ EXPECT_EQ("baz`", Args::EscapeLLDBCommandArgument(baz, '\''));
+ EXPECT_EQ("baz`", Args::EscapeLLDBCommandArgument(baz, '`'));
+ EXPECT_EQ("baz\\`", Args::EscapeLLDBCommandArgument(baz, '"'));
+
+ const std::string quux = "quux\t";
+ EXPECT_EQ("quux\\\t", Args::EscapeLLDBCommandArgument(quux, '\0'));
+ EXPECT_EQ("quux\t", Args::EscapeLLDBCommandArgument(quux, '\''));
+ EXPECT_EQ("quux\t", Args::EscapeLLDBCommandArgument(quux, '`'));
+ EXPECT_EQ("quux\t", Args::EscapeLLDBCommandArgument(quux, '"'));
+}
Index: source/Utility/Args.cpp
===================================================================
--- source/Utility/Args.cpp
+++ source/Utility/Args.cpp
@@ -640,14 +640,15 @@
case '\0':
chars_to_escape = " \t\\'\"`";
break;
- case '\'':
- chars_to_escape = "";
- break;
case '"':
chars_to_escape = "$\"`\\";
break;
+ case '`':
+ case '\'':
+ return arg;
default:
assert(false && "Unhandled quote character");
+ return arg;
}
std::string res;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59779.192139.patch
Type: text/x-patch
Size: 2041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190325/5d0de69a/attachment-0001.bin>
More information about the lldb-commits
mailing list