Skip to content

Commit

Permalink
Be sure to remove the stream filters on the message objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrubinsk committed May 5, 2015
1 parent 49264c5 commit 775c6bc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
Expand Up @@ -41,6 +41,8 @@
*/
class Horde_ActiveSync_Message_AirSyncBaseFileAttachment extends Horde_ActiveSync_Message_Base
{
protected $_streamfilter = false;

/**
* Property map
*
Expand All @@ -65,6 +67,14 @@ class Horde_ActiveSync_Message_AirSyncBaseFileAttachment extends Horde_ActiveSyn
'data' => false,
);

protected function __destruct()
{
parent::__destruct();
if (!empty($this->_streamfilter)) {
stream_filter_remove($this->_streamfilter);
}
}

/**
* Return the message type.
*
Expand All @@ -89,7 +99,7 @@ protected function _checkEncoding($data, $tag)
{
if ($tag == Horde_ActiveSync_Request_ItemOperations::ITEMOPERATIONS_DATA) {
if (is_resource($data)) {
stream_filter_append($data, 'convert.base64-encode', STREAM_FILTER_READ);
$this->_streamfilter = stream_filter_append($data, 'convert.base64-encode', STREAM_FILTER_READ);
} else {
$data = base64_encode($data);
}
Expand Down
18 changes: 16 additions & 2 deletions framework/ActiveSync/lib/Horde/ActiveSync/Message/Base.php
Expand Up @@ -109,6 +109,9 @@ class Horde_ActiveSync_Message_Base
*/
protected $_device;

protected $_filter_eol = false;
protected $_filter_null = false;

/**
* Const'r
*
Expand Down Expand Up @@ -136,6 +139,16 @@ public function __construct(array $options = array())
}
}

public function __destruct()
{
if (!empty($this->_filter_eol)) {
stream_filter_remove($this->_filter_eol);
}
if (!empty($this->_filter_null)) {
stream_filter_remove($this->_filter_null);
}
}

/**
* Return the EAS version this object supports.
*
Expand Down Expand Up @@ -499,8 +512,9 @@ protected function _checkEncoding($data, $tag)
if (is_resource($data)) {
stream_filter_register('horde_null', 'Horde_Stream_Filter_Null');
stream_filter_register('horde_eol', 'Horde_Stream_Filter_Eol');
$filter_null = stream_filter_prepend($data, 'horde_null', STREAM_FILTER_READ);
$filter_eol = stream_filter_prepend($data, 'horde_eol', STREAM_FILTER_READ);
$this->_filter_null = stream_filter_prepend($data, 'horde_null', STREAM_FILTER_READ);
$this->_filter_eol = stream_filter_prepend($data, 'horde_eol', STREAM_FILTER_READ);

}
return $data;
}
Expand Down

0 comments on commit 775c6bc

Please sign in to comment.