fmbiete / Z-Push-contrib

Z-Push fork with changes that I will try to contrib
GNU Affero General Public License v3.0
134 stars 62 forks source link

Device fails to properly display delivery error reports #213

Closed ghost closed 9 years ago

ghost commented 9 years ago

The mimeDecode.php function only grabs the attachments properly if the call to it has _rfc822_bodies set. But this flag is not set in the case where a status response is found (typically) so you get zero-length attachments which of course cannot be displayed. In addition they are not flagged inline but should be (a status report by definition is inline) so the device mishandles the attachment types.

The following diff to /usr/share/z-push/include/mimeDecode.php corrects both flaws and allows proper display of delivery failure reports:

*** /usr/share/z-push/include/mimeDecode.php    Tue Jun 16 14:27:02 2015
--- mimeDecode.php      Mon Jun 29 11:48:02 2015
***************
*** 369,379 ****

                  case 'message/rfc822':
                  case 'message/delivery-status': // #bug #18693
!                     if ($this->_rfc822_bodies) {
                          $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
                          $charset = isset($return->ctype_parameters['charset']) ? $return->ctype_parameters['charset'] : $this->_charset;
                          $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding, $charset, false) : $body);
!                     }

                      $obj = new Mail_mimeDecode($body);
                      $return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies,
--- 369,380 ----

                  case 'message/rfc822':
                  case 'message/delivery-status': // #bug #18693
! // KD 2015-06-29 Always use rfc822 bodies for status responses and 
! // always inline them because there is no "type" to them (they're text)
                          $encoding = isset($content_transfer_encoding) ? $content_transfer_encoding['value'] : '7bit';
                          $charset = isset($return->ctype_parameters['charset']) ? $return->ctype_parameters['charset'] : $this->_charset;
                          $return->body = ($this->_decode_bodies ? $this->_decodeBody($body, $encoding, $charset, false) : $body);
!                       $return->disposition = 'inline';

                      $obj = new Mail_mimeDecode($body);
                      $return->parts[] = $obj->decode(array('include_bodies' => $this->_include_bodies,
fmbiete commented 9 years ago

I think it's better to set the rfc822_bodies param to true in the BackendIMAP. Thank you very much for your hard work!!!