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

[MIME] Towards parsing + rendering #34224

Closed
jchook opened this issue Nov 2, 2019 · 10 comments
Closed

[MIME] Towards parsing + rendering #34224

jchook opened this issue Nov 2, 2019 · 10 comments

Comments

@jchook
Copy link

jchook commented Nov 2, 2019

Description

Re: symfony/mime.

Code that renders and parses MIME appears to live scattered within the AST, and enforces some unnecessary rigidity as a result. For example, we have a general lack of control over rendering details like the hard-coded boundary prefixes that remain difficult to circumvent, and no plans for general MIME parsing capabilities.

Imagine extracting the outermost rendering and parsing code into Renderer and Parser classes.

Such a refactor could pave the way towards an unprecedented "full-duplex" PHP MIME parsing + rendering library that could parse a MIME document, examine, modify, and re-render it, (e.g. perhaps with a different transfer encoding), all with OO fine-tuning of parsing and rendering logic.

Example

use Symfony\Component\Mime\Textual\Parser;
use Symfony\Component\Mime\Textual\Renderer;

$mimeString = '...';
$parser = new Parser();
$message = $parser->parseMessage($mimeString);

$renderer = new Renderer();
$renderer->renderMessage($message);
@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@jchook
Copy link
Author

jchook commented Dec 18, 2020

After posting this I went ahead and wrote a MIME parser/renderer that uses this principle.

It works well and has 100% test coverage, but it's very slow. Perhaps I could publish it as a proof of concept and we could look into the idea more?

@carsonbot carsonbot removed the Stalled label Dec 18, 2020
@scuben
Copy link
Contributor

scuben commented Dec 18, 2020

Hi @jchook, do you have that parser publicly available to have a look at?

@jchook
Copy link
Author

jchook commented Dec 18, 2020

@scuben, just pushed it to GitHub here: https://github.com/jchook/mime-php

@aistis-
Copy link

aistis- commented Mar 2, 2021

That's a great idea! I also have use case for that.

@carsonbot
Copy link

Thank you for this suggestion.
There has not been a lot of activity here for a while. Would you still like to see this feature?

@jchook
Copy link
Author

jchook commented Sep 8, 2021

Yes I would

@carsonbot carsonbot removed the Stalled label Sep 8, 2021
@wouterj
Copy link
Member

wouterj commented Sep 8, 2021

The next question is: Is anyone up to writing this?

No matter how cool features are, after 2 years we just need someone to write the actual thing. If there is nobody there to do this (which is totally fine - OSS remains a purely motivational driven process), I'm afraid we have to close this as stalled (meaning we do not close it because we reject the feature, but because it doesn't make sense to have stalled features in our very long issue list).

@jchook
Copy link
Author

jchook commented Sep 9, 2021

I did write it.

Though I understand this project is rather entrenched and will likely not adopt a major refactor like this.

@jchook jchook closed this as completed Sep 9, 2021
@aistis-
Copy link

aistis- commented Sep 9, 2021

@jchook would it be difficult to implement only a Parser feature to the symfony? I ended up using php-mime-mail-parser for parsing and a custom transformer to Symfony's Message

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

No branches or pull requests

6 participants