Skip to content

bpo-44660: Updated email.feedparser with support for message/global emails with quoted-printable and base64 Content-Transfer-Encodings. #27208

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

f18a14c09s
Copy link

@f18a14c09s f18a14c09s commented Jul 17, 2021

Fixed issue 44660: email.feedparser Module Lacks Support for Section 3.5 of RFC 6532: message/global Emails with non-identity Content-Transfer-Encodings as follows:
Added message/global Content-Transfer-Encoding section to _parsegen function; three supporting classes; and a supporting function.
Added unit test coverage for the subject scenarios.

https://bugs.python.org/issue44660

Added message/global Content-Transfer-Encoding section to _parsegen function, three supporting classes, and a supporting function.
Added parsing coverage for base64 and quoted-printable Content-Transfer-Encodings.
@the-knights-who-say-ni
Copy link

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

Recognized GitHub username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@f18a14c09s

This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Copy link
Contributor

@jdevries3133 jdevries3133 left a comment

Choose a reason for hiding this comment

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

Very nice!



class NonIdentityTransferDecodingFeedParser(abc.ABC):
"""
Copy link
Contributor

Choose a reason for hiding this comment

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

hanging indent on the docstring looks strange to me; consult PEP 257


class Base64TransferDecodingFeedParser(NonIdentityTransferDecodingFeedParser):
"""
Concrete, "base64" implementation of TransferDecodingFeedParser.
Copy link
Contributor

Choose a reason for hiding this comment

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

This docstring, and the docstring for QuotedPrintableTransferDecodingFeedParser seem redundant. Seeing as the class and base class names are quite descriptive, maybe just provide an RFC (or other) citation in the docstrings?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I incorporated the recommendation in a massive update I'm about to apply.

Creates a new FeedParser object that transparently reverses the specified
content_transfer_encoding transformation.
:param content_transfer_encoding: str
:return: Union[NoneType,NonIdentityTransferDecodingFeedParser] None if
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're going to provide this information, use type hints:

def _new_transfer_decoding_parser(content_transfer_encoding: str, **kwargs
    ) -> Union[NoneType, NonIdentityTransferDecodingFeedParser]: 

Formatting is tricky because the bass class name is so long. Maybe consider shortening it a bit: NoIdTransDecodingFP. I don't really love that abbreviation myself and I like the current descriptive name, but it is quite a mouthful.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I incorporated the recommendation in a massive update I'm about to apply.

Replaced decoding-parser factory method with Content-Transfer-Encoding (str) to factory (function) map.
Removed the word "transfer" from the TransferDecoding-related classes, functions, variables, etc. to be more concise and because there is already sufficient context.
Removed the word "nonidentity" from class NonIdentityTransferDecodingFeedParser's name and updated the docstrings/comments explaining why the word is redundant.
Moved base-64-only functionality to new class in base64mime sub-package.
Accounted for edge cases in QuotedPrintableFeedParser so that it could be made a standalone feature if desired.
Added/updated code comments.
@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Aug 18, 2021
@github-actions github-actions bot removed the stale Stale PR or inactive for long period of time. label Aug 10, 2022
@python-cla-bot
Copy link

The following commit authors need to sign the Contributor License Agreement:

CLA signed

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

Successfully merging this pull request may close these issues.

5 participants