Announcement

Collapse
No announcement yet.

Attachment files corrupted

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Attachment files corrupted

    Attached files from emails in some encodings are corrupted.
    Test (original and corrupted files in files.zip):
    1. Send original file as attachment to group email account
    (2)The mail is imported into the system
    3. Download attached file.
    (4) File is corrupted!
    Attached Files

  • #2
    I tested and it worked fine. Might be email client specific. Could you attach an original (raw contents of the email)?

    Comment


    • #3
      Mail sended from yandex to google.
      In zip mail sources
      Attached Files

      Comment


      • #4
        Also I check file in data\upload directory. It is already corrupted. File downloaded from google ok. Problem with import.

        Screenshot - unix cat command on modified and original files.

        Original file size is 2498 and in database attachment size is 2498 but file data\upload\5e8f4d8eeb47c3e0f file size is 2500
        Attached Files
        Last edited by dimyy; 04-09-2020, 05:29 PM.

        Comment


        • #5
          The only problem with the file is "뿃뻃" in the beginning?

          Comment


          • #6
            Windows notepad can read the file, but with a few extra characters in the beginning. The problem must be with mail mime parser library. But could be with yandex too (google might just fix the problem email). I will try the newer version of mail mime parser but I don't believe this is fixed there.

            Comment


            • #7
              Yes.
              Original file (in HEX): ff fe
              Corrupted: c3 bf c3 be

              Yandex sended source and google received source is the same.

              Comment


              • #8
                Updating zbateson/mail-mime-parser to the latest 1.2.0 version didn't help.

                Comment


                • #9


                  It's not good news. We have this error about 3-5 times a month. Usualy problem with pdf file, but yesterday we received big text file and I was able to reproduce error with small piece of that file.

                  Comment


                  • #10
                    I figured out that it treats it as UTF-8, but it's encoded in UTF-16.

                    If I manually add charset=utf-16; to content-type of the attachment it will parse it properly.

                    I'm not sure whether it's the fault of the library or attachment part is formatted not according standards.

                    Comment


                    • #11
                      May be this function have error:


                      Charset is https://github.com/zbateson/mail-mim...Stream.php#L65

                      But test try use utf-16: https://github.com/zbateson/mail-mim...ryTest.php#L47

                      And this helper is already fixed for correct reading from UTF-16LE streams https://github.com/zbateson/stream-d...rsetStream.php

                      Comment


                      • #12
                        Here is the fix: https://github.com/espocrm/espocrm/c...06a9ea0ba491e8

                        Not very nice. I think it would be better to just get raw contents and store it for every attachment. Need more testing.

                        Could you provide problem email with pdf? I think it's another issue.

                        Comment


                        • #13
                          Fix is installed. I wait pdf with error (typical beeline bill) and report here

                          Comment


                          • #14
                            All OK. PDF imported without error.

                            Comment


                            • #15
                              That fix should not have affected PDF files. It deals only with text/plain and text/html.

                              Comment

                              Working...
                              X