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

  • Home
  • SEARCH
  • 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 1104945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:33:17+00:00 2026-05-17T01:33:17+00:00

I have an app engine app that receives incoming mail with attachments. I check

  • 0

I have an app engine app that receives incoming mail with attachments. I check the attachment filename to make sure that the extension is correct. If the filename has umlauts or accented characters in it the encoding makes the filename unreadable to my methods, so I don’t know how to check the file type.

For example, if I send a file with name ZumBrückenwirtÜberGrünwaldZurück(2).gpx

And then print out the attachment name like this:

 attachments = [message.attachments]        
 attachmenttype = attachments[0][0][-4:].lower()  
 logging.error("attachment name %s, %s" % (attachments[0][0], attachmenttype))

I get:

attachment name =?ISO-8859-1?B?WnVtQnL8Y2tlbndpcnTcYmVyR3L8bndhbGRadXL8Y2soMikuZ3B4?=, b4?=

  • 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-17T01:33:17+00:00Added an answer on May 17, 2026 at 1:33 am

    That’s an RFC2047 encoded-word. You can partially decode it with the email package, although it still needs stitching together afterwards:

    import email.header
    def parseHeader(h):
        return ''.join(s.decode(c or 'us-ascii') for s, c in email.header.decode_header(h))
    
    >>> parseHeader('=?ISO-8859-1?B?WnVtQnL8Y2tlbndpcnTcYmVyR3L8bndhbGRadXL8Y2soMikuZ3B4?=')
    u'ZumBr\xfcckenwirt\xdcberGr\xfcnwaldZur\xfcck(2).gpx'
    

    It is, however, utterly incorrect to use an encoded-word in the filename="..." parameter for Content-Disposition in an attachment. RFC2047 explicitly states that an encoded-word cannot appear in a quoted paramter. Non-ASCII parameter values are supposed to be transferred using the rules of RFC2231, which look completely different (and very complicated).

    So according to the mail standard, you should treat this filename as literally being “=?ISO-8859-1?B?WnVtQnL8Y2tlbndpc…”. I believe it’s MS Exchange that generates this nonsense. Try to keep this processing down to a minimum (eg. by only decoding when the string is wrapped in =?...?= which is pretty unlikely for a filename.

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

Sidebar

Related Questions

I have a simple Google App Engine app, that I wrote using ordinary strings.
I'm using Google App Engine and Django templates. I have a table that I
I'm a newbie to python and the app engine. I have this code that
In my app I have a search engine that returns list of results. The
I have a Google App Engine app - http://mylovelyapp.appspot.com/ It has a page -
So I have this code in a google app engine template: <select name='voter'> {%
As the title suggests, I'm using Google App Engine and Django. I have quite
I have an app that needs to open a new window (in the same
I have an application that is required to check the versions of various system
I have a web app that users upload files to. I want to authenticate

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.