diff options
-rwxr-xr-x | redis/client.py | 5 | ||||
-rw-r--r-- | tests/test_monitor.py | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py index 3471895..5cf778c 100755 --- a/redis/client.py +++ b/redis/client.py @@ -3344,7 +3344,10 @@ class Monitor(object): m = self.monitor_re.match(command_data) db_id, client_info, command = m.groups() command = ' '.join(self.command_re.findall(command)) - command = command.replace('\\"', '"').replace('\\\\', '\\') + # Redis escapes double quotes because each piece of the command + # string is surrounded by double quotes. We don't have that + # requirement so remove the escaping and leave the quote. + command = command.replace('\\"', '"') if client_info == 'lua': client_address = 'lua' diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 0e39ec0..ee5dc6e 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -34,6 +34,13 @@ class TestMonitor(object): response = wait_for_command(r, m, 'GET foo\\x92') assert response['command'] == 'GET foo\\x92' + def test_command_with_escaped_data(self, r): + with r.monitor() as m: + byte_string = b'foo\\x92' + r.get(byte_string) + response = wait_for_command(r, m, 'GET foo\\\\x92') + assert response['command'] == 'GET foo\\\\x92' + def test_lua_script(self, r): with r.monitor() as m: script = 'return redis.call("GET", "foo")' |