Commit d656e5a8 authored by Ralf Becker's avatar Ralf Becker

ZP-702 Attachments are 1 or 2 bytes short. Released under the Affero GNU...

ZP-702 Attachments are 1 or 2 bytes short. Released under the Affero GNU General Public License (AGPL) version 3.
Fixed empty attachment data written, because stream was not at the beginning eg. by a previous call to fstat.
Also logging now number of bytes written and not length of stream, to be able to detect similar problems.
parent 9cd3657b
...@@ -315,18 +315,18 @@ class WBXMLEncoder extends WBXMLDefs { ...@@ -315,18 +315,18 @@ class WBXMLEncoder extends WBXMLDefs {
private function _contentStream($stream, $asBase64) { private function _contentStream($stream, $asBase64) {
// write full stream, including the finalizing terminator to the output stream (stuff outTermStr() would do) // write full stream, including the finalizing terminator to the output stream (stuff outTermStr() would do)
$this->outByte(WBXML_STR_I); $this->outByte(WBXML_STR_I);
fseek($stream, 0, SEEK_SET);
if ($asBase64) { if ($asBase64) {
$out_filter = stream_filter_append($this->_out, 'convert.base64-encode'); $out_filter = stream_filter_append($this->_out, 'convert.base64-encode');
} }
stream_copy_to_stream($stream, $this->_out); $written = stream_copy_to_stream($stream, $this->_out);
if ($asBase64) { if ($asBase64) {
stream_filter_remove($out_filter); stream_filter_remove($out_filter);
} }
fwrite($this->_out, chr(0)); fwrite($this->_out, chr(0));
// data is out, do some logging // data is out, do some logging
$stat = fstat($stream); $logContent = sprintf("<<< %d bytes of %s data >>>", $written, $asBase64 ? "base64 encoded":"plain");
$logContent = sprintf("<<< %d bytes of %s data >>>", $stat['size'], $asBase64 ? "base64 encoded":"plain");
$this->logContent($logContent); $this->logContent($logContent);
// write the meta data also to the _outLog stream, WBXML_STR_I was already written by outByte() above // write the meta data also to the _outLog stream, WBXML_STR_I was already written by outByte() above
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment