From: Gunnar Wrobel Date: Thu, 16 Dec 2010 14:32:08 +0000 (+0100) Subject: Base64 encode token strings to allow them to contain newlines. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f8fbce65bc45c7e91b9a02abd2f1f1bf06d5a215;p=horde.git Base64 encode token strings to allow them to contain newlines. The initial timestamp that was recently added to the tokens may match the binary representation of a newline which kills the file based token driver (which is line oriented). Should fix the flaky token test. --- diff --git a/framework/Token/lib/Horde/Token/File.php b/framework/Token/lib/Horde/Token/File.php index e445552fd..c29f77fe3 100644 --- a/framework/Token/lib/Horde/Token/File.php +++ b/framework/Token/lib/Horde/Token/File.php @@ -93,10 +93,11 @@ class Horde_Token_File extends Horde_Token_Base $this->_connect(); /* Find already used IDs. */ + $token = base64_encode($tokenID); $fileContents = file($this->_params['token_dir'] . '/conn_' . $this->_encodeRemoteAddress()); if ($fileContents) { for ($i = 0, $iMax = count($fileContents); $i < $iMax; ++$i) { - if (chop($fileContents[$i]) == $tokenID) { + if (chop($fileContents[$i]) == $token) { return true; } } @@ -117,7 +118,8 @@ class Horde_Token_File extends Horde_Token_Base $this->_connect(); /* Write the entry. */ - fwrite($this->_fd, $tokenID . "\n"); + $token = base64_encode($tokenID); + fwrite($this->_fd, $token . "\n"); $this->_disconnect(); }