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.header unicode fix #44723

Closed
tkikuchi mannequin opened this issue Mar 15, 2007 · 7 comments
Closed

email.header unicode fix #44723

tkikuchi mannequin opened this issue Mar 15, 2007 · 7 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@tkikuchi
Copy link
Mannequin

tkikuchi mannequin commented Mar 15, 2007

BPO 1681333
Nosy @warsaw, @bitdancer
Files
  • email_header_unicode.patch: email_header_unicode.patch
  • 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/bitdancer'
    closed_at = <Date 2011-03-17.03:46:28.713>
    created_at = <Date 2007-03-15.11:13:52.000>
    labels = ['easy', 'type-bug', 'library']
    title = 'email.header unicode fix'
    updated_at = <Date 2011-03-17.15:23:15.273>
    user = 'https://bugs.python.org/tkikuchi'

    bugs.python.org fields:

    activity = <Date 2011-03-17.15:23:15.273>
    actor = 'barry'
    assignee = 'r.david.murray'
    closed = True
    closed_date = <Date 2011-03-17.03:46:28.713>
    closer = 'r.david.murray'
    components = ['Library (Lib)']
    creation = <Date 2007-03-15.11:13:52.000>
    creator = 'tkikuchi'
    dependencies = []
    files = ['7883']
    hgrepos = []
    issue_num = 1681333
    keywords = ['patch', 'easy']
    message_count = 7.0
    messages = ['52236', '52237', '110567', '131213', '131223', '131243', '131261']
    nosy_count = 4.0
    nosy_names = ['barry', 'tkikuchi', 'r.david.murray', 'BreamoreBoy']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = 'patch review'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue1681333'
    versions = ['Python 3.1', 'Python 2.7', 'Python 3.2', 'Python 3.3']

    @tkikuchi
    Copy link
    Mannequin Author

    tkikuchi mannequin commented Mar 15, 2007

    email.header.Header class has its unicode representation which is slightly different from str representation.

    >>> h = email.Header.make_header((('[XXX]', 'us-ascii'), ('Re:', 'us-ascii')))
    >>> unicode(h)
    u'[XXX]Re:'
    >>> str(h)
    '[XXX] Re:'

    Note that a white space between ']' and 'R' is absent from unicode representation. A word-separating space should be needed in following contexts:

    lastcs \ nextcs | ascii | other |
    ascii | sp | sp |
    other | sp | nosp |

    Current code fails to put a space for ascii\ascii case.

    Also, if the ascii string has a trailing space, it may result in a extraneous double space which has semantically equivalent to a single space and sometimes annoying. You should use qp encoding for ascii charset if you insist on the presence of the space.

    The patch includes test code. :)

    @tkikuchi tkikuchi mannequin assigned warsaw Mar 15, 2007
    @tkikuchi tkikuchi mannequin added the stdlib Python modules in the Lib dir label Mar 15, 2007
    @tkikuchi tkikuchi mannequin assigned warsaw Mar 15, 2007
    @tkikuchi tkikuchi mannequin added the stdlib Python modules in the Lib dir label Mar 15, 2007
    @tkikuchi
    Copy link
    Mannequin Author

    tkikuchi mannequin commented Mar 16, 2007

    Sorry but I am withdrawing the latter part of the patch for ascii encoding. Revised patch is for only unicode representation.

    File Added: email_header_unicode.patch

    @devdanzin devdanzin mannequin added type-bug An unexpected behavior, bug, or error labels Mar 30, 2009
    @devdanzin devdanzin mannequin added easy labels Apr 22, 2009
    @warsaw warsaw assigned bitdancer and unassigned warsaw May 5, 2010
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jul 17, 2010

    Applied the patches to the test files for 2.6.5 without patching header.py and got one failure.

    FAIL: test_i18nheader_unicode (email.test.test_email.TestRFC2047)

    I also expected a failure from the equivalent test for test_email_renamed, can someone please advise.

    @bitdancer
    Copy link
    Member

    I'm rejecting this. There is more than one bug here, but it starts with the fact that ('xxx', None) is treated the same as ('xxx', 'us-ascii'). In the first case it would be nice if a space was used to separate two of them in a row. In the second case a space should not be used, since it should in fact be an encoded word.

    The documentation for make_header says it takes a list produced by decode_header. decode_header will never produce two ('xxx', None) tuples in a row. It could produce a tuple with us-ascii preceeded or followed by one with None, but that would be only if the us-ascii one really was an encoded word, and so encoded word spacing rules should be followed.

    However, the current quirks are of such long standing that I don't think it is a good idea to fix them. The broken behavior won't be encountered in any reasonable email, and changing the behvior is much more likely to break existing oddball uses of the interface than it is to fix bugs in such uses.

    We'll fix this to work right in email6.

    @tkikuchi
    Copy link
    Mannequin Author

    tkikuchi mannequin commented Mar 17, 2011

    OK. I understand but slightly disappointed because four years have passed since this issue was raised and these years are included in the 'such long standing' period.

    @bitdancer
    Copy link
    Member

    Yes, I can well understand that feeling. I've only relatively recently taken over maintaining the email package. I'm working my way through the old bug queue, and I can only deal with them in the context in which I find them.

    @warsaw
    Copy link
    Member

    warsaw commented Mar 17, 2011

    Sadly, I agree with RDM. There are too many workarounds in the field for this bug so it can really only be fixed in email6.

    @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
    easy stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants