Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6184011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:27:47+00:00 2026-05-24T01:27:47+00:00

I get a HeaderParseError if I try to parse this string with decode_header() in

  • 0

I get a HeaderParseError if I try to parse this string with decode_header() in python 2.6.5 (and 2.7). Here the repr() of the string:

 '=?iso-8859-1?B?QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?='

This string comes from a mime email which contains a JPEG picture. Thunderbird can
decode the filename (which contains German umlauts).

>>> from email.header import decode_header
>>> decode_header('=?iso-8859-1?B?QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw==?=')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/email/header.py", line 101, in decode_header
    raise HeaderParseError
email.errors.HeaderParseError
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:27:48+00:00Added an answer on May 24, 2026 at 1:27 am

    It seems an incompatibility between Python’s character set for base64-encoded strings and the mail agent’s:

    >>> from email.header import decode_header
    >>> a='QW5tZWxkdW5nIE5ldHphbnNjaGx1c3MgU_xkcmluZzNwLmpwZw=='
    >>> decode_header(a)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/lib/python2.7/email/header.py", line 108, in decode_header
        raise HeaderParseError
    email.errors.HeaderParseError
    >>> a1= a.replace('_', '/')
    >>> decode_header(a1)
    [('Anmeldung Netzanschluss S\xecdring3p.jpg', 'iso-8859-1')]
    >>> print _[0][0].decode(_[0][1])
    Anmeldung Netzanschluss Südring3p.jpg
    

    Python utilizes the character set that the Wikipedia article suggests (i.e 0-9, A-Z, a-z, +, /). In that same article, some alternatives (including the underscore that’s the issue here) are included; however, the underscore’s value is vague (it’s value 62 or 63, depending on the alternative).

    I don’t know what Python can do to guess the intentions of b0rken mail agents; so I suggest you do some appropriate guessing whenever decode_header fails.

    I’m calling “broken” the mail agent because there is no need to escape either + or / in a message header: it’s not a URL, so why not use the typical character set?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error: Cannot refer to an instance member of a class from
get this from my database: 252.587254564 Well i wanna remove the .587254564 and keep
I get this response from an Ajax request. Javascript seems to intepret it as
We get a large amount of data from our clients in pdf files in
I get a URL from a user. I need to know: a) is the
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get an XML file From a web service. Now I want to get
I get this error on an update panel within a popupControlExtender which is within
Get value out of DateTime column if null to return String.Empty else DateTime.ToShortDateString What
Get the following error periodically in an IIS application: Failed to load resources from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.