Handling of backslashes in CLI client "unexpected" #755

Closed
sgbeal opened this Issue Nov 6, 2012 · 6 comments

Comments

Projects
None yet
6 participants

sgbeal commented Nov 6, 2012

LOL: i was having a discussion with a colleague about why we should NOT use hard tabs for separators in our redis db and accidentally found a bug: the CLI client seems to mis-handle keys which contain the escape sequence \t (it was trying to prove to my colleague that there is "no way" the CLI client interprets that as a tab):

  redis 127.0.0.1:6379> set "blah\tblah" foo
  OK
  redis 127.0.0.1:6379> set "blahblah" foo
  OK
  redis 127.0.0.1:6379> keys b*
  1) "blah\blah"
  2) "blahblah"
  redis 127.0.0.1:6379> del "blah\blah"
  (integer) 0
  redis 127.0.0.1:6379> del blahblah
  (integer) 1
  redis 127.0.0.1:6379> keys b*
  1) "blah\blah"
  redis 127.0.0.1:6379> del blah\blah
  (integer) 0
  redis 127.0.0.1:6379> del blah\tblah
  (integer) 0
  redis 127.0.0.1:6379> keys *
  1) "blah\blah"
  redis 127.0.0.1:6379> del blah\\blah
  (integer) 0
  redis 127.0.0.1:6379> keys *
  1) "blah\blah"

i am not sure how i can delete this key (not that i need to - this is a dummy instance).

Contributor

charsyam commented Nov 7, 2012

how about using del "blah\tblah"

moreaki commented Nov 7, 2012

Just tested on redis-server 2.6.2:

redis 127.0.0.1:6379> FLUSHDB
OK
redis 127.0.0.1:6379> KEYS *
(empty list or set)
redis 127.0.0.1:6379> set "blah\tblah" foo
OK
redis 127.0.0.1:6379> set "blah\\blah" foo
OK
redis 127.0.0.1:6379> set "blah\n\blah" foo
OK
redis 127.0.0.1:6379> KEYS *
1) "blah\n\blah"
2) "blah\\blah"
3) "blah\tblah"
redis 127.0.0.1:6379> del "blah\tblah"
(integer) 1
redis 127.0.0.1:6379> del "blah\\blah"
(integer) 1
redis 127.0.0.1:6379> del "blah\n\blah"
(integer) 1
redis 127.0.0.1:6379> KEYS *
(empty list or set)

As noted by @charsyam, you have tested GNU readline rather than the SET command of redis. So wrap your escape characters into quotes "<chars>".

Contributor

charsyam commented Nov 7, 2012

my result is also similar with @moreaki

charsyam@ubuntu:~/projects/redis$ src/redis-cli
redis 127.0.0.1:6379> set "blah\tblah" foo
OK
redis 127.0.0.1:6379> set "blahblah" foo
OK
redis 127.0.0.1:6379> keys *

  1. "bar"
  2. "blahblah"
  3. "key"
  4. "blah\tblah"
    redis 127.0.0.1:6379> keys b*
  5. "bar"
  6. "blahblah"
  7. "blah\tblah"
    redis 127.0.0.1:6379> del blah\tblah
    (integer) 0
    redis 127.0.0.1:6379> del "blah\tblah"
    (integer) 1
    redis 127.0.0.1:6379>
Contributor

badboy commented Nov 7, 2012

@moreaki Just to clarify this: redis-cli does not use readline, but linenoise, antirez' own alternative to readline (with similar behaviour)

moreaki commented Nov 7, 2012

@badboy: That's exactly true, thank you for mentioning it. In fact I wish we'd replace existing GNU tools (for example the notoriously big bash) with linenoise to reduce the noise and have significantly smaller binaries for let's say ARM environments. I hope Chet Ramey won't be offended by this ;).

ellisio referenced this issue in laravel/framework Aug 12, 2013

Closed

Adding namespace fix. #2082

mattsta closed this Aug 1, 2014

For anyone stumbling upon this issue, this article could apply if you're using Git bash for Windows. http://stackoverflow.com/questions/37051203/how-do-i-pass-a-literal-forward-slash-into-node-js-in-git-bash-for-windows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment