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

bpo-29412: patched string index out of range error in get_word function of _head… #6907

Closed

Conversation

TyrannosourceExe
Copy link

@TyrannosourceExe TyrannosourceExe commented May 16, 2018

…er_value_parser.py and created tests in test__header_value_parser.py for empty string.

bpo-29412: patched string index out of range error in get_word function of _header_value_parser.py by checking for empty string.  Empty string is returned by get_cfws(value)[1] when everything is CFWS.

Backport Pull Request title

Changes suggested to be applied to python 3.5 , 3.6 , and 3.7

https://bugs.python.org/issue29412

…er_value_parser.py and created tests in test__header_value_parser.py for CFWS.
@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 your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

When your account is ready, please add a comment in this pull request
and a Python core developer will remove the CLA not signed label
to make the bot check again.

Thanks again to your contribution and we look forward to looking at it!

@TyrannosourceExe TyrannosourceExe changed the title patched string index out of range error in get_word function of _head… bpo-29412: patched string index out of range error in get_word function of _head… May 16, 2018
@TyrannosourceExe
Copy link
Author

I verified that I signed the CLA. let me know if there is anything else I need to do! :)

else:
token, value = get_atom(value)
if leader is not None:
token[:0] = [leader]
Copy link
Member

Choose a reason for hiding this comment

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

Should be no need to copy these two lines from below.

@bebarino
Copy link

bebarino commented Feb 6, 2019

I'm running into this bug in the alot package (the pazz/alot#1367 referenced bug above). I'm using python 3.5 so I've backported this fix there and I run into another issue where the backtrace ends like this:

    values = mail.get_all(key)
  File "/usr/lib/python3.5/email/message.py", line 511, in get_all
    values.append(self.policy.header_fetch_parse(k, v))
  File "/usr/lib/python3.5/email/policy.py", line 160, in header_fetch_parse
    return self.header_factory(name, value)
  File "/usr/lib/python3.5/email/headerregistry.py", line 586, in __call__
    return self[name](name, value)
  File "/usr/lib/python3.5/email/headerregistry.py", line 197, in __new__
    cls.parse(value, kwds)
  File "/usr/lib/python3.5/email/headerregistry.py", line 344, in parse
    for mb in addr.all_mailboxes]))
  File "/usr/lib/python3.5/email/headerregistry.py", line 344, in <listcomp>
    for mb in addr.all_mailboxes]))
AttributeError: 'Group' object has no attribute 'local_part'

So this change isn't fixing everything for me, but maybe that's because on python 3.5 there's something else missing? The header that's failing is

To: unlisted-recipients:; (no To-header on input)

in case that helps here.

@meskio
Copy link

meskio commented Feb 12, 2019

I have tested the patch (removing the two lines mentioned by @zooba) and it fixes the issue for me (using python 3.7).

@TyrannosourceExe Do you mind removing this two lines? I will love to see this merged.

@maxking
Copy link
Contributor

maxking commented Jun 14, 2019

Since @TyrannosourceExe hasn't responded in a while, I am willing to pick up this patch and get it merged. I'll wait for a week or though if @TyrannosourceExe wants to work on the comments.

@meskio
Copy link

meskio commented Jun 14, 2019

@maxking thanks for picking this up. I was hitting it daily with my email client, I end up patching the email library in my system, and after 4 months using this patch I haven't have problems.

@csabella
Copy link
Contributor

csabella commented Jul 3, 2019

Merged under GH-14387. Thanks, @maxking!

@csabella csabella closed this Jul 3, 2019
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.

9 participants