|
5 | 5 |
|
6 | 6 |
|
7 | 7 |
|
| 8 | +// This mess could need some cleanup! |
8 | 9 | if (isset($_POST['commands'])) { |
9 | 10 | $commands = explode("\n", $_POST['commands']); |
10 | 11 |
|
|
22 | 23 | // We can't just explode since we might have \" inside the key. So do a preg_split on " with a negative lookbehind assertions to make sure it isn't a \". |
23 | 24 | $key = preg_split('/(?<!\\\\)"/', substr($command[1], 1), 2); |
24 | 25 |
|
| 26 | + $key[0] = stripslashes($key[0]); |
| 27 | + |
25 | 28 | // Strip the seperating space |
26 | 29 | $key[1] = substr($key[1], 1); |
27 | 30 | } else { |
|
30 | 33 |
|
31 | 34 | switch ($command[0]) { |
32 | 35 | case 'SET': { |
33 | | - // Trim the optional "" acount th value. |
34 | | - $redis->set($key[0], trim($key[1], '"')); |
| 36 | + if ($key[1][0] == '"') { |
| 37 | + $val = stripslashes(trim($key[1], '"')); |
| 38 | + } else { |
| 39 | + $val = $key[1]; |
| 40 | + } |
| 41 | + |
| 42 | + $redis->set($key[0], $val); |
35 | 43 | break; |
36 | 44 | } |
37 | 45 |
|
38 | 46 | case 'HSET': { |
39 | 47 | if ($key[1][0] == '"') { |
40 | 48 | // See preg_split above. |
41 | 49 | $hkey = preg_split('/(?<!\\\\)"/', substr($key[1], 1), 2); |
| 50 | + |
| 51 | + $hkey[0] = stripslashes($hkey[0]); |
42 | 52 |
|
43 | 53 | // Strip the seperating space |
44 | 54 | $hkey[1] = substr($hkey[1], 1); |
45 | 55 | } else { |
46 | 56 | $hkey = explode(' ', $key[1], 2); |
47 | 57 | } |
48 | 58 |
|
49 | | - $redis->hSet($key[0], $hkey[0], trim($hkey[1], '"')); |
| 59 | + if ($hkey[1][0] == '"') { |
| 60 | + $val = stripslashes(trim($hkey[1], '"')); |
| 61 | + } else { |
| 62 | + $val = $hkey[1]; |
| 63 | + } |
| 64 | + |
| 65 | + $redis->hSet($key[0], $hkey[0], $val); |
50 | 66 | break; |
51 | 67 | } |
52 | 68 |
|
53 | 69 | case 'RPUSH': { |
54 | | - $redis->rPush($key[0], trim($key[1], '"')); |
| 70 | + if ($key[1][0] == '"') { |
| 71 | + $val = stripslashes(trim($key[1], '"')); |
| 72 | + } else { |
| 73 | + $val = $key[1]; |
| 74 | + } |
| 75 | + |
| 76 | + $redis->rPush($key[0], $val); |
55 | 77 | break; |
56 | 78 | } |
57 | 79 |
|
58 | 80 | case 'SADD': { |
59 | | - $redis->sAdd($key[0], trim($key[1], '"')); |
| 81 | + if ($key[1][0] == '"') { |
| 82 | + $val = stripslashes(trim($key[1], '"')); |
| 83 | + } else { |
| 84 | + $val = $key[1]; |
| 85 | + } |
| 86 | + |
| 87 | + $redis->sAdd($key[0], $val); |
60 | 88 | break; |
61 | 89 | } |
62 | 90 |
|
63 | 91 | case 'ZADD': { |
64 | 92 | if ($key[1][0] == '"') { |
65 | 93 | // See preg_split ebove. |
66 | 94 | $score = preg_split('/(?<!\\\\)"/', substr($key[1], 1), 2); |
| 95 | + |
| 96 | + $score[0] = stripslashes($score[0]); |
67 | 97 |
|
68 | 98 | // Strip the seperating space |
69 | 99 | $score[1] = substr($score[1], 1); |
70 | 100 | } else { |
71 | 101 | $score = explode(' ', $key[1], 2); |
72 | 102 | } |
73 | 103 |
|
74 | | - $redis->zAdd($key[0], $score[0], trim($score[1], '"')); |
| 104 | + if ($score[1][0] == '"') { |
| 105 | + $val = stripslashes(trim($score[1], '"')); |
| 106 | + } else { |
| 107 | + $val = $score[1]; |
| 108 | + } |
| 109 | + |
| 110 | + $redis->zAdd($key[0], $score[0], $val); |
75 | 111 | break; |
76 | 112 | } |
77 | 113 |
|
|
80 | 116 | } |
81 | 117 |
|
82 | 118 |
|
83 | | - |
84 | 119 | // Refresh the top so the key tree is updated. |
85 | 120 | require 'header.inc.php'; |
86 | 121 |
|
|
0 commit comments