mirror of
https://github.com/fluencelabs/redis
synced 2025-06-24 14:31:34 +00:00
Add tests for quotation in an interactive redis-cli session
Patched redis-cli to abort on unexpected quotation. This caused redis-cli to get into an infinite, memory-consuming loop.
This commit is contained in:
@ -66,4 +66,23 @@ start_server {tags {"cli"}} {
|
||||
r rpush list bar
|
||||
assert_equal "1. \"foo\"\n2. \"bar\"" [run_command $fd "lrange list 0 -1"]
|
||||
}
|
||||
|
||||
test_interactive_cli "Parsing quotes" {
|
||||
assert_equal "OK" [run_command $fd "set key \"bar\""]
|
||||
assert_equal "bar" [r get key]
|
||||
assert_equal "OK" [run_command $fd "set key \" bar \""]
|
||||
assert_equal " bar " [r get key]
|
||||
assert_equal "OK" [run_command $fd "set key \"\\\"bar\\\"\""]
|
||||
assert_equal "\"bar\"" [r get key]
|
||||
assert_equal "OK" [run_command $fd "set key \"\tbar\t\""]
|
||||
assert_equal "\tbar\t" [r get key]
|
||||
|
||||
# invalid quotation
|
||||
assert_equal "Invalid argument(s)" [run_command $fd "get \"\"key"]
|
||||
assert_equal "Invalid argument(s)" [run_command $fd "get \"key\"x"]
|
||||
|
||||
# quotes after the argument are weird, but should be allowed
|
||||
assert_equal "OK" [run_command $fd "set key\"\" bar"]
|
||||
assert_equal "bar" [r get key]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user