Skip to content

Commit

Permalink
Remove useless helper method.
Browse files Browse the repository at this point in the history
  • Loading branch information
yunosh committed Jan 26, 2015
1 parent d5d7bba commit db708b4
Showing 1 changed file with 10 additions and 30 deletions.
40 changes: 10 additions & 30 deletions framework/ManageSieve/lib/Horde/ManageSieve.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
* @license http://www.horde.org/licenses/bsd BSD
*/

/**
* TODO
*
* o supportsAuthMech()
*/

namespace Horde;
use Horde\ManageSieve;
use Horde\ManageSieve\Exception;
Expand Down Expand Up @@ -760,11 +754,13 @@ protected function _cmdPutScript($scriptname, $scriptdata)
throw new NotAuthenticated();
}

$stringLength = $this->_getLineLength($scriptdata);
$command = sprintf("PUTSCRIPT %s {%d+}\r\n%s",
$this->_escape($scriptname),
$stringLength,
$scriptdata);
$command = sprintf(
"PUTSCRIPT %s {%d+}\r\n%s",
$this->_escape($scriptname),
strlen($scriptdata),
$scriptdata
);

$this->_doCmd($command);
}

Expand Down Expand Up @@ -869,7 +865,7 @@ protected function _sendCmd($cmd)
*/
protected function _sendStringResponse($str)
{
return $this->_sendCmd('{' . $this->_getLineLength($str) . "+}\r\n" . $str);
return $this->_sendCmd('{' . strlen($str) . "+}\r\n" . $str);
}

/**
Expand Down Expand Up @@ -909,7 +905,7 @@ protected function _recvBytes($length)
$response_length = 0;
while ($response_length < $length) {
$response .= $this->_sock->read($length - $response_length);
$response_length = $this->_getLineLength($response);
$response_length = strlen($response);
}
$this->_debug('S: ' . rtrim($response));
return $response;
Expand Down Expand Up @@ -1087,22 +1083,6 @@ protected function _startTLS()
}
}

/**
* Returns the length of a string.
*
* @param string $string A string.
*
* @return integer The length of the string.
*/
protected function _getLineLength($string)
{
if (extension_loaded('mbstring')) {
return mb_strlen($string, 'latin1');
} else {
return strlen($string);
}
}

/**
* Locale independant strtoupper() implementation.
*
Expand Down Expand Up @@ -1131,7 +1111,7 @@ protected function _escape($string)
// Some implementations don't allow UTF-8 characters in quoted-string,
// use literal-c2s.
if (preg_match('/[^\x01-\x09\x0B-\x0C\x0E-\x7F]/', $string)) {
return sprintf("{%d+}\r\n%s", $this->_getLineLength($string), $string);
return sprintf("{%d+}\r\n%s", strlen($string), $string);
}

return '"' . addcslashes($string, '\\"') . '"';
Expand Down

0 comments on commit db708b4

Please sign in to comment.