Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

bug in parser/parts/text_parser.php #54

Closed
sebastienlhaire opened this issue Nov 30, 2016 · 4 comments
Closed

bug in parser/parts/text_parser.php #54

sebastienlhaire opened this issue Nov 30, 2016 · 4 comments

Comments

@sebastienlhaire
Copy link

in method finish() charset conversion should not be activated when text is already utf-8.

my version:

    /**
     * Returns the ezcMailText part corresponding to the parsed message.
     *
     * @return ezcMailText
     */
    public function finish()
    {
        $charset = "us-ascii"; // RFC 2822 default
        if ( isset( $this->headers['Content-Type'] ) )
        {
            preg_match( '/\s*charset\s?=\s?"?([^;"\s]*);?/i',
                            $this->headers['Content-Type'],
                            $parameters );
            if ( count( $parameters ) > 0 )
            {
                $charset = strtolower( trim( $parameters[1], '"' ) );
            }
        }

        $encoding = strtolower( $this->headers['Content-Transfer-Encoding'] );
        if ( $encoding == ezcMail::QUOTED_PRINTABLE )
        {
            $this->text = quoted_printable_decode( $this->text );
        }
        else if ( $encoding == ezcMail::BASE64 )
        {
            $this->text = base64_decode( $this->text );
        }
        if ($charset != 'utf-8') {
            $this->text = ezcMailCharsetConverter::convertToUTF8($this->text, $charset);
        }

        $part = new ezcMailText( $this->text, 'utf-8', ezcMail::EIGHT_BIT, $charset );
        $part->subType = $this->subType;
        $part->setHeaders( $this->headers->getCaseSensitiveArray() );
        ezcMailPartParser::parsePartHeaders( $this->headers, $part );
        $part->size = strlen( $this->text );
        return $part;
    }
@derickr
Copy link
Member

derickr commented Dec 13, 2016

Do you have an example email that shows this problem? We are going to need that to make a patch and a test for this.

@sebastienlhaire
Copy link
Author

Unfortunately I cannot remember which mail caused the problem. I have rolled back the code to your latest version and tried successfully to parse various mails. If I come across a mail which can reproduce the bug, I send it to you.

@derickr
Copy link
Member

derickr commented Jan 8, 2020

Is this still a live issue for you? If not, I will close it in the next few days.

@derickr
Copy link
Member

derickr commented Jun 13, 2020

Closing this out due to inactivity

@derickr derickr closed this as completed Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants