Jump to content

Decoding Quoted-Printable MIME attachment corrupted zip file


mcfloyd

Recommended Posts

Hello,

  I'm having a huge issue right now decoding a zip file from an attachment with a content-encoding of quoted-printable.  I have tried a couple different methods (such as decoding the entire attachment or decoding it line by line), but none have produced a valid file when saved.  What I don't understand is that I can download and open the file in Outlook fine, so there must be something wrong with the decoder.  Here is a code snippet of my recent attempt:

                            elseif ($transferEncoding == 'quoted-printable'){
                                $fileError = true;
                                $attachmentParts = explode("\n", $currentPart->getContent());
                                $attachmentArray = array();
                                foreach ($attachmentParts as $line){
                                    array_push($attachmentArray, quoted_printable_decode($line));
                                }
                                $attachment = implode("", $attachmentArray);
                                file_put_contents($unzipPath . '.zip', $attachment);
                            }
                            $unzipper = new Decompress(array(
                                'adapter' => 'Zip',
                                'options' => array(
                                    'target' => $unzipPath,
                                )
                            ));
                            $unzipper->filter($unzipPath . '.zip');
                            unlink($unzipPath . '.zip');

I'm using Zend Framework 2 methods for unzipping the file when it's done, but there is a CRC error because the file is getting corrupted during the decode.

 

This is how the file compares to the original (using Beyond Compare 3):

OwYhkbm.png

 

So it is finding the hex for CLRF and removing it from the file.

 

Any ideas on this would be greatly appreciated as I have been trying to solve this for about a month now.

 

Thanks,

-mcfloyd

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.