]> git.saurik.com Git - redis.git/commitdiff
sdscatrepr() fixed. Now newlines and other special chars are escaped correctly
authorantirez <antirez@gmail.com>
Sun, 20 Mar 2011 17:24:49 +0000 (18:24 +0100)
committerantirez <antirez@gmail.com>
Sun, 20 Mar 2011 17:24:49 +0000 (18:24 +0100)
src/sds.c

index 67e2d4565965677269ec7a27f1a792a0d1b23606..5f78f1ebad9aa1a42bfda01a577dd1a18e6366bf 100644 (file)
--- a/src/sds.c
+++ b/src/sds.c
@@ -399,11 +399,11 @@ sds sdscatrepr(sds s, char *p, size_t len) {
         case '"':
             s = sdscatprintf(s,"\\%c",*p);
             break;
-        case '\n': s = sdscatlen(s,"\\n",1); break;
-        case '\r': s = sdscatlen(s,"\\r",1); break;
-        case '\t': s = sdscatlen(s,"\\t",1); break;
-        case '\a': s = sdscatlen(s,"\\a",1); break;
-        case '\b': s = sdscatlen(s,"\\b",1); break;
+        case '\n': s = sdscatlen(s,"\\n",2); break;
+        case '\r': s = sdscatlen(s,"\\r",2); break;
+        case '\t': s = sdscatlen(s,"\\t",2); break;
+        case '\a': s = sdscatlen(s,"\\a",2); break;
+        case '\b': s = sdscatlen(s,"\\b",2); break;
         default:
             if (isprint(*p))
                 s = sdscatprintf(s,"%c",*p);