diff options
author | Elliott Hughes <enh@google.com> | 2015-04-17 20:50:11 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-04-17 20:55:04 -0700 |
commit | 5498adefb00cd979137361b98fcbf8d51f72ebeb (patch) | |
tree | d7fe6a85a8b7e34b05a8ddac53f98657a9d54626 /adb/adb_utils_test.cpp | |
parent | 623aa1c47a51990259fbbc271d7f9f40046153fd (diff) | |
download | system_core-5498adefb00cd979137361b98fcbf8d51f72ebeb.zip system_core-5498adefb00cd979137361b98fcbf8d51f72ebeb.tar.gz system_core-5498adefb00cd979137361b98fcbf8d51f72ebeb.tar.bz2 |
Use ' quoting to escape arguments.
The specific motivating case is "text;ls;1.apk", but rather than continue
adding individual characters to the list of characters to be escaped, let's
just switch to quote all arguments with ', which only leaves ' itself to be
escaped.
Bug: 20323053
Bug: 19734868
Change-Id: I8bd71db9373bc2d1169fc11e46c889da6638550a
Diffstat (limited to 'adb/adb_utils_test.cpp')
-rw-r--r-- | adb/adb_utils_test.cpp | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/adb/adb_utils_test.cpp b/adb/adb_utils_test.cpp index 95e28a8..a395079 100644 --- a/adb/adb_utils_test.cpp +++ b/adb/adb_utils_test.cpp @@ -25,28 +25,28 @@ TEST(adb_utils, directory_exists) { } TEST(adb_utils, escape_arg) { - ASSERT_EQ(R"("")", escape_arg("")); - - ASSERT_EQ(R"(abc)", escape_arg("abc")); - - ASSERT_EQ(R"(\ abc)", escape_arg(" abc")); - ASSERT_EQ(R"(\'abc)", escape_arg("'abc")); - ASSERT_EQ(R"(\"abc)", escape_arg("\"abc")); - ASSERT_EQ(R"(\\abc)", escape_arg("\\abc")); - ASSERT_EQ(R"(\(abc)", escape_arg("(abc")); - ASSERT_EQ(R"(\)abc)", escape_arg(")abc")); - - ASSERT_EQ(R"(abc\ abc)", escape_arg("abc abc")); - ASSERT_EQ(R"(abc\'abc)", escape_arg("abc'abc")); - ASSERT_EQ(R"(abc\"abc)", escape_arg("abc\"abc")); - ASSERT_EQ(R"(abc\\abc)", escape_arg("abc\\abc")); - ASSERT_EQ(R"(abc\(abc)", escape_arg("abc(abc")); - ASSERT_EQ(R"(abc\)abc)", escape_arg("abc)abc")); - - ASSERT_EQ(R"(abc\ )", escape_arg("abc ")); - ASSERT_EQ(R"(abc\')", escape_arg("abc'")); - ASSERT_EQ(R"(abc\")", escape_arg("abc\"")); - ASSERT_EQ(R"(abc\\)", escape_arg("abc\\")); - ASSERT_EQ(R"(abc\()", escape_arg("abc(")); - ASSERT_EQ(R"(abc\))", escape_arg("abc)")); + ASSERT_EQ(R"('')", escape_arg("")); + + ASSERT_EQ(R"('abc')", escape_arg("abc")); + + ASSERT_EQ(R"(' abc')", escape_arg(" abc")); + ASSERT_EQ(R"('\'abc')", escape_arg("'abc")); + ASSERT_EQ(R"('"abc')", escape_arg("\"abc")); + ASSERT_EQ(R"('\abc')", escape_arg("\\abc")); + ASSERT_EQ(R"('(abc')", escape_arg("(abc")); + ASSERT_EQ(R"(')abc')", escape_arg(")abc")); + + ASSERT_EQ(R"('abc abc')", escape_arg("abc abc")); + ASSERT_EQ(R"('abc\'abc')", escape_arg("abc'abc")); + ASSERT_EQ(R"('abc"abc')", escape_arg("abc\"abc")); + ASSERT_EQ(R"('abc\abc')", escape_arg("abc\\abc")); + ASSERT_EQ(R"('abc(abc')", escape_arg("abc(abc")); + ASSERT_EQ(R"('abc)abc')", escape_arg("abc)abc")); + + ASSERT_EQ(R"('abc ')", escape_arg("abc ")); + ASSERT_EQ(R"('abc\'')", escape_arg("abc'")); + ASSERT_EQ(R"('abc"')", escape_arg("abc\"")); + ASSERT_EQ(R"('abc\')", escape_arg("abc\\")); + ASSERT_EQ(R"('abc(')", escape_arg("abc(")); + ASSERT_EQ(R"('abc)')", escape_arg("abc)")); } |