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

email.Utils.py: UnicodeError in RFC2322 header #42834

Closed
qbin mannequin opened this issue Jan 24, 2006 · 2 comments
Closed

email.Utils.py: UnicodeError in RFC2322 header #42834

qbin mannequin opened this issue Jan 24, 2006 · 2 comments
Assignees
Labels
stdlib Python modules in the Lib dir

Comments

@qbin
Copy link
Mannequin

qbin mannequin commented Jan 24, 2006

BPO 1414018
Nosy @warsaw
Files
  • conversion_error.eml: sample email
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/warsaw'
    closed_at = <Date 2006-07-28.03:19:44.000>
    created_at = <Date 2006-01-24.20:19:55.000>
    labels = ['library']
    title = 'email.Utils.py: UnicodeError in RFC2322 header'
    updated_at = <Date 2006-07-28.03:19:44.000>
    user = 'https://bugs.python.org/qbin'

    bugs.python.org fields:

    activity = <Date 2006-07-28.03:19:44.000>
    actor = 'barry'
    assignee = 'barry'
    closed = True
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2006-01-24.20:19:55.000>
    creator = 'qbin'
    dependencies = []
    files = ['1883']
    hgrepos = []
    issue_num = 1414018
    keywords = []
    message_count = 2.0
    messages = ['27352', '27353']
    nosy_count = 2.0
    nosy_names = ['barry', 'qbin']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1414018'
    versions = ['Python 2.4']

    @qbin
    Copy link
    Mannequin Author

    qbin mannequin commented Jan 24, 2006

    Description:
    collapse_rfc2231_value does not handle UnicodeError
    exception. Therefore a header like this one can cause
    UnicodeError in attempting unicode conversion.

    ---
    Content-Type: text/plain; charset="ISO-2022-JP"
    Content-Disposition: attachment;
    filename*=iso-2022-jp''%1B%24BJs9p%3Dq%2D%21%1B%28B%2Etxt
    ---

    Test script:
    ---

    #! /usr/bin/env python
    import sys
    import email
    
    msg = email.message_from_file(sys.stdin)
    for part in msg.walk():
      print part.get_params()
      print part.get_filename()

    run
    % env LANG=ja_JP.eucJP ./test.py < attached_sample.eml

    Background:
    Character 0x2d21 is invalid in JIS X0208 but defined in
    CP932 (Shift_JIS's superset by Microsoft). Conversion
    between Shift_JIS and ISO-2022-JP are computable
    because both of them based on JIS X0208. So sometimes
    CP932 characters appear in ISO-2022-JP encoded string,
    typically produced by Windows MUA.
    But Python's "ISO-2022-JP" means *pure* JIS X0208, thus
    conversion is failed.

    Workaround:
    Convert to fallback_charset and/or skip invalid character.

    @qbin qbin mannequin closed this as completed Jan 24, 2006
    @qbin qbin mannequin assigned warsaw Jan 24, 2006
    @qbin qbin mannequin added the stdlib Python modules in the Lib dir label Jan 24, 2006
    @qbin qbin mannequin closed this as completed Jan 24, 2006
    @qbin qbin mannequin assigned warsaw Jan 24, 2006
    @qbin qbin mannequin added the stdlib Python modules in the Lib dir label Jan 24, 2006
    @warsaw
    Copy link
    Member

    warsaw commented Jul 28, 2006

    Logged In: YES
    user_id=12800

    r50894 for Python 2.4/email 3.0. This is already fixed in
    Python 2.5/email 4.0

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant