Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

tests: Mail\Message produced output not usable by Storage\Message #159

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

glensc
Copy link
Contributor

@glensc glensc commented Jul 20, 2017

this shows the problem zend-mail is having:

mail created with Mail\Message and serialized into raw
and then loaded with Storage\Message causes parse error if the $text contains double unix newlines (\n\n).

        $text = "Hello, bödi tekst\n\nBye";

        $part = new Mime\Part($text);
        $part->type = 'text/plain';
        $part->charset = 'UTF-8';

        $mime = new Mime\Message();
        $mime->addPart($part);

        $message = new Mail\Message();
        $message->setEncoding('UTF-8');
        $message->setBody($text);

        $raw = $message->toString();
        $message = new Storage\Message(['raw' => $raw]);

this throws on $message = new Storage\Message(['raw' => $raw]);

`

glensc added a commit to glensc/eventum that referenced this pull request Jul 20, 2017
zendframework/zend-mail#159

Current workaround is to split headers+body ourselves from raw message.
glensc added a commit to glensc/eventum that referenced this pull request Jul 24, 2017
zendframework/zend-mail#159

Current workaround is to split headers+body ourselves from raw message.
glensc added a commit to glensc/eventum that referenced this pull request Sep 4, 2017
zendframework/zend-mail#159

Current workaround is to split headers+body ourselves from raw message.
$part->charset = 'UTF-8';

$mime = new Mime\Message();
$mime->addPart($part);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the preceding 7 lines are ever used within the test. Is your setup missing something (attaching a MIME part to the message)? Or can the lines be removed safely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think they can be removed as the reproducer worked. otherwise i wouldn't had pushed it this way.

$raw = $message->toString();
$this->assertContains($text, $raw, "original text is preserved");

$message = new Storage\Message(['raw' => $raw]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a Zend\Mime\Decode::splitMessage() issue.

Zend\Mail\Storage\Part calls on that method to split the message into headers and content. My suspicion is that it's searching until the last occurence of the \n\n sequence, instead of the first.

Can you please try and create and post a reproduce case against the zend-mime component? Thanks in advance!

@weierophinney
Copy link
Member

This repository has been moved to laminas/laminas-mail. If you feel that this patch is still relevant, please re-open against that repository, and reference this issue. To re-open, we suggest the following workflow:

  • Squash all commits in your branch (git rebase -i origin/{branch})
  • Make a note of all changed files (`git diff --name-only origin/{branch}...HEAD
  • Run the laminas/laminas-migration tool on the code.
  • Clone laminas/laminas-mail to another directory.
  • Copy the files from the second bullet point to the clone of laminas/laminas-mail.
  • In your clone of laminas/laminas-mail, commit the files, push to your fork, and open the new PR.
    We will be providing tooling via laminas/laminas-migration soon to help automate the process.

@michalbundyra
Copy link
Member

This repository has been closed and moved to laminas/laminas-mail; a new issue has been opened at laminas/laminas-mail#43.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants