Attachment files corrupted

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dimyy
    Active Community Member
    • Jun 2018
    • 569

    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
  • yuri
    Member
    • Mar 2014
    • 8510

    #2
    I tested and it worked fine. Might be email client specific. Could you attach an original (raw contents of the email)?
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • dimyy
      Active Community Member
      • Jun 2018
      • 569

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

      Comment

      • dimyy
        Active Community Member
        • Jun 2018
        • 569

        #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

        • yuri
          Member
          • Mar 2014
          • 8510

          #5
          The only problem with the file is "뿃뻃" in the beginning?
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • yuri
            Member
            • Mar 2014
            • 8510

            #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.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • dimyy
              Active Community Member
              • Jun 2018
              • 569

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

              Yandex sended source and google received source is the same.

              Comment

              • yuri
                Member
                • Mar 2014
                • 8510

                #8
                Updating zbateson/mail-mime-parser to the latest 1.2.0 version didn't help.
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment

                • dimyy
                  Active Community Member
                  • Jun 2018
                  • 569

                  #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

                  • yuri
                    Member
                    • Mar 2014
                    • 8510

                    #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.
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment

                    • dimyy
                      Active Community Member
                      • Jun 2018
                      • 569

                      #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

                      • yuri
                        Member
                        • Mar 2014
                        • 8510

                        #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.
                        If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                        Comment

                        • dimyy
                          Active Community Member
                          • Jun 2018
                          • 569

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

                          Comment

                          • dimyy
                            Active Community Member
                            • Jun 2018
                            • 569

                            #14
                            All OK. PDF imported without error.

                            Comment

                            • yuri
                              Member
                              • Mar 2014
                              • 8510

                              #15
                              That fix should not have affected PDF files. It deals only with text/plain and text/html.
                              If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                              Comment

                              Working...