diff options
author | Elliott Hughes <enh@google.com> | 2015-05-04 19:29:32 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-05-05 12:45:42 -0700 |
commit | aceb9c08df80da9c929af2998c54870455b79a03 (patch) | |
tree | a15e1eeee89d7433494080ae6526718cb7d39522 /adb/tests | |
parent | 7d678d8d78b40c9c7697565637ba5e4dc81ec02f (diff) | |
download | system_core-aceb9c08df80da9c929af2998c54870455b79a03.zip system_core-aceb9c08df80da9c929af2998c54870455b79a03.tar.gz system_core-aceb9c08df80da9c929af2998c54870455b79a03.tar.bz2 |
Implement the ssh(1) escaping rules.
The first rule of ssh(1) escaping is that there is no escaping.
This doesn't undo any of my recent security fixes because they're all
calling escape_arg themselves.
This fixes "adb shell rm /data/dalvik-cache/arm/*".
Also remove do_cmd which caused concern during code review.
Bug: http://b/20564385
Change-Id: I4588fd949d51e2a50cff47ea171ed2d75f402d0d
(cherry picked from commit 2b10111d25adcfe3627103b73edad22f188c97ba)
Diffstat (limited to 'adb/tests')
-rwxr-xr-x | adb/tests/test_adb.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/adb/tests/test_adb.py b/adb/tests/test_adb.py index 52d8056..237ef47 100755 --- a/adb/tests/test_adb.py +++ b/adb/tests/test_adb.py @@ -272,13 +272,24 @@ class AdbBasic(unittest.TestCase): adb = AdbWrapper() # http://b/19734868 + # Note that this actually matches ssh(1)'s behavior --- it's + # converted to "sh -c echo hello; echo world" which sh interprets + # as "sh -c echo" (with an argument to that shell of "hello"), + # and then "echo world" back in the first shell. result = adb.shell("sh -c 'echo hello; echo world'").splitlines() + self.assertEqual(["", "world"], result) + # If you really wanted "hello" and "world", here's what you'd do: + result = adb.shell("echo hello\;echo world").splitlines() self.assertEqual(["hello", "world"], result) # http://b/15479704 self.assertEqual('t', adb.shell("'true && echo t'").strip()) self.assertEqual('t', adb.shell("sh -c 'true && echo t'").strip()) + # http://b/20564385 + self.assertEqual('t', adb.shell("FOO=a BAR=b echo t").strip()) + self.assertEqual('123Linux', adb.shell("echo -n 123\;uname").strip()) + class AdbFile(unittest.TestCase): SCRATCH_DIR = "/data/local/tmp" |