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

HeaderParseError #1

Closed
jasonblewis opened this issue Apr 18, 2011 · 5 comments
Closed

HeaderParseError #1

jasonblewis opened this issue Apr 18, 2011 · 5 comments

Comments

@jasonblewis
Copy link

Hi,

I'm having this problem with cleanup-maildir when i run it on a large folder of mail, i get this error:

Traceback (most recent call last):
File "./cleanup-maildir", line 504, in
cleaner.clean(mode, dir, minAge)
File "./cleanup-maildir", line 405, in clean
self.log(logging.DEBUG, "Keeping #%d (fresh)" % i, msg)
File "./cleanup-maildir", line 410, in log
subj = msgObj.getSubject()
File "./cleanup-maildir", line 209, in getSubject
email.Header.decode_header(s)))
File "/usr/lib/python2.6/email/header.py", line 101, in decode_header
raise HeaderParseError
email.errors.HeaderParseError

i added some debug code, to try and get more info, but I'm no expert in python so i'm a bit lost as to how i might get more info.

i changed the code to read:
def getSubject(self):
"""get the message's subject as a unicode string"""

    import email.Header
    s = self.getheader("Subject")
    try:
        print "DEBUG: subject=", s
        return u"".join(map(lambda x: x[0].decode(x[1] or 'ASCII', 'replace'),
                            email.Header.decode_header(s)))
    except(LookupError):
        return s
    except:
        print "Unexpected error:", sys.exc_info()[0]
        print "email.Header.decode_header(s) s =", s
        raise

also note -
here is my debug output
INFO:MaildirCleaner:(Not really) Archiving #18127 to a Reference.2007: TCF: UNS: Segfault in Samba
DEBUG: subject= eBay Favourite Search: m-audio
INFO:MaildirCleaner:(Not really) Archiving #18128 to a Reference.2007: eBay Favourite Search: m-audio
DEBUG: subject= Updated barcodes showing essdale park counter stand with barcode
DEBUG: subject= =?UTF-8?B?VGhhbmsgeW91IGZvciB5b3VyIGZlZWRi?==?UTF-8?B?YWNr?=
Unexpected error: <class 'email.errors.HeaderParseError'>
email.Header.decode_header(s) s = =?UTF-8?B?VGhhbmsgeW91IGZvciB5b3VyIGZlZWRi?==?UTF-8?B?YWNr?=

see how the header is funny for the last one that seems to cause the error?

any suggestions?

Jason

@jasonblewis
Copy link
Author

I tracked down the bug to an issue with how unicode subjects are encoded sometimes incorrectly by mail agents.

see the discussion here: http://bugs.python.org/issue10574#msg122776

ill post a patch shortly

@jpforte
Copy link

jpforte commented Dec 12, 2014

I am having this problem. Any update?

@jvc
Copy link
Owner

jvc commented Dec 12, 2014

Sorry.. I don't have any updates and haven't used it in a few years.
On Dec 12, 2014 6:58 AM, "jpforte" notifications@github.com wrote:

I am having this problem. Any update?


Reply to this email directly or view it on GitHub
#1 (comment).

@jpforte
Copy link

jpforte commented Dec 12, 2014

Ahh too bad it's a great utility

Jim Forte
MAGNA Timeshare Software
Magna VEGA, (vacation equities)
407-352-2402,5050
Http://www.magna.net
Mailto:james@Magna.Net
Sent from my iPhone

On Dec 12, 2014, at 8:33 AM, Justin Chouinard notifications@github.com wrote:

Sorry.. I don't have any updates and haven't used it in a few years.
On Dec 12, 2014 6:58 AM, "jpforte" notifications@github.com wrote:

I am having this problem. Any update?


Reply to this email directly or view it on GitHub
#1 (comment).


Reply to this email directly or view it on GitHub.

@jvc
Copy link
Owner

jvc commented Dec 12, 2014

You might try using a mail client to move the message that the script is
having a problem with.
On Dec 12, 2014 8:45 AM, "jpforte" notifications@github.com wrote:

Ahh too bad it's a great utility

Jim Forte
MAGNA Timeshare Software
Magna VEGA, (vacation equities)
407-352-2402,5050
Http://www.magna.net
Mailto:james@Magna.Net
Sent from my iPhone

On Dec 12, 2014, at 8:33 AM, Justin Chouinard notifications@github.com
wrote:

Sorry.. I don't have any updates and haven't used it in a few years.
On Dec 12, 2014 6:58 AM, "jpforte" notifications@github.com wrote:

I am having this problem. Any update?


Reply to this email directly or view it on GitHub
#1 (comment).


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#1 (comment).

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

3 participants