• Upgraded to the last webapp (kopano-webapp_4.0.2676+1570.1), but still some attachments don’t download. Attachment is about 100Kb in size. (PDF)

    I had a customer who had a mail with 4 attachments, only the last one could be downloaded. Tried to download them all in a ZIP. The ZIP was made but only 1 out of 4 attachments where in the ZIP.

    Anybody with a tip how to debug this? Browser console log does not show any script errors…

  • Kopano

    Hi @TuxTiger,

    i’d recommend to check for error messages. You could check the console of your browser, the webserver logging or logging of kopano-server. It may be required to change log verbosity to get additional insights.

  • The apache logs show no errors, just 200 in the access log.

    The response headers are indicating that a PDF is going to be delivered:

    ache-Control: must-revalidate, post-check=0, pre-check=0
    Connection: Keep-Alive
    Content-Length: 98396
    Content-Transfer-Encoding: binary
    Content-Type: application/pdf
    Date: Sat, 21 Mar 2020 22:50:20 GMT
    Expires: 0
    Keep-Alive: timeout=5, max=100
    Pragma: public
    Server: Apache
    Set-Cookie: lang=en_US.UTF-8; path=/; secure
    Strict-Transport-Security: max-age=31536000; includeSubDomainsi; preload
    X-Frame-Options: SAMEORIGIN
    X-Zarafa: 4.0.2676+1570.1

    but the response (according to Chrome network debug) is:

    <!doctype html><html><body style='height: 100%; width: 100%; overflow: hidden; margin:0px; background-color: rgb(82, 86, 89);'><embed style='position:absolute; left: 0; top: 0;'width='100%' height='100%' src='about:blank' type='application/pdf' internalid='2787C575D8E188ED45E23AC9BA5C9D40'></embed></body></html>

    Kopano server-log is clean (loglevel 5)

  • The problem lies in the fact that the attachment filename has \r\n in de filename. The mail was received from our water company but I had another customer who received the pdf from his broker. So it is not some freak incident, apparently this can happen…


    You can ‘see’ the \r\n present in the webinterface

    These characters break the header function therefore the Content-Disposition header is missing.

    My fix, but maybe you want it in function browserDependingHTTPHeaderEncode:

    diff --git a/server/includes/download_attachment.php b/server/includes/download_attachment.php
    index 332abbe3..135df45d 100644
    --- a/server/includes/download_attachment.php
    +++ b/server/includes/download_attachment.php
    @@ -344,7 +344,7 @@ class DownloadAttachment extends DownloadBase
                            header('Pragma: public');
                            header('Expires: 0'); // set expiration time
                            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    -                       header('Content-Disposition: ' . $this->contentDispositionType . '; filename="' . addslashes(browserDependingHTTPHeaderEncode($filename)) . '"');
    +                       header('Content-Disposition: ' . $this->contentDispositionType . '; filename="' . addslashes(preg_replace("/\r|\n/", "", browserDependingHTTPHeaderEncode($filename))) . '"');
                            header('Content-Type: ' . $contentType);
                            header('Content-Transfer-Encoding: binary');
  • Kopano


    Based on your suggestion we made a ticket and a fix: https://jira.kopano.io/browse/KW-3408