Permalink
Browse files

Handle 2.6-format INFO output

Redis 2.6.x changes its INFO to divide the data into sections, with blank
lines and comments separating them.  Ensure that we don't let such things
escape into the data returned.

Tested against Redis 2.6.0-rc5.
  • Loading branch information...
1 parent 8313695 commit 7cb7b677f8467137f3be8de20d668a1d2a43a830 @arc arc committed Jun 16, 2012
Showing with 6 additions and 2 deletions.
  1. +1 −1 lib/Redis.pm
  2. +5 −1 t/01-basic.t
View
@@ -221,7 +221,7 @@ sub info {
my $custom_decode = sub {
my ($reply) = @_;
return $reply if !defined $reply || ref $reply;
- return { map { split(/:/, $_, 2) } split(/\r\n/, $reply) };
+ return { map { split(/:/, $_, 2) } grep { /^[^#]/ } split(/\r\n/, $reply) };
};
my $cb = @_ && ref $_[-1] eq 'CODE' ? pop : undef;
View
@@ -331,7 +331,11 @@ ok($o->lastsave, 'lastsave');
## Remote server control commands
ok(my $info = $o->info, 'info');
-isa_ok($info, 'HASH');
+isa_ok($info, 'HASH', '... yields a hash');
+ok(keys %$info, '... nonempty');
+unlike(join("\n", keys %$info), qr/#/, '... with no comments in the keys');
+unlike(join("\n", keys %$info), qr/\n\n|\A\n|\n\z/,
+ '... with no blank lines in the keys');
## Connection handling

0 comments on commit 7cb7b67

Please sign in to comment.