Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

windows mail encoding order #10

Open
charlymz opened this issue Dec 7, 2012 · 1 comment
Open

windows mail encoding order #10

charlymz opened this issue Dec 7, 2012 · 1 comment

Comments

@charlymz
Copy link

charlymz commented Dec 7, 2012

i detected a bug where a mail send from windows mail on windows 8 wasnt parsing ok
--739CC2DA-F094-4259-95D2-56B6A454FCFF
Content-Transfer-Encoding: base64
Content-Type: text/html; charset="utf-8"

this is part o fthe mail notice the order of Content-Transfer-Encoding first then Content-Type
changed function public function getBody($returnType=self::PLAINTEXT) between lines 213 - 248 to deal with this

    foreach ($this->rawBodyLines as $line) {

        if (!$detectedContentType || $waitingForContentStart || $contentTransferEncoding == null) {

            if (preg_match($contentTypeRegex, $line, $matches)) {
                $detectedContentType = true;
            }

            if(preg_match('/charset=(.*)/i', $line, $matches)) {
                $charset = strtoupper(trim($matches[1], '"')); 
            }                 

            if ($contentTransferEncoding == null && preg_match('/^Content-Transfer-Encoding: ?(.*)/i', $line, $matches)) {
                $contentTransferEncoding = $matches[1];
            }                

            if (self::isNewLine($line) && $detectedContentType && $contentTransferEncoding != null) {
                $waitingForContentStart = false;
            }
        } else {  // ($detectedContentType && !$waitingForContentStart)
            // collecting the actual content until we find the delimiter

            // if the delimited is AAAAA, the line will be --AAAAA  - that's why we use substr
            if (is_array($boundaries)) {
                if (in_array(substr($line, 2), $boundaries)) {  // found the delimiter
                    break;
                }
            }
            $body .= $line . "\n";
        }
    }
@appastair
Copy link

If you've tested your changes, commit them or (as it's a minor modification) in your browser then do a Pull Request.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants