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

CGI library - Using unicode in header fields #70714

Closed
OlivierLeMoign mannequin opened this issue Mar 10, 2016 · 4 comments
Closed

CGI library - Using unicode in header fields #70714

OlivierLeMoign mannequin opened this issue Mar 10, 2016 · 4 comments
Labels
topic-unicode type-bug An unexpected behavior, bug, or error

Comments

@OlivierLeMoign
Copy link
Mannequin

OlivierLeMoign mannequin commented Mar 10, 2016

BPO 26527
Nosy @vstinner, @ezio-melotti, @vadmium
Superseder
  • bpo-23434: support encoded filename in Content-Disposition for HTTP in cgi.FieldStorage
  • 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 = None
    closed_at = None
    created_at = <Date 2016-03-10.11:04:31.918>
    labels = ['type-bug', 'expert-unicode']
    title = 'CGI library - Using unicode in header fields'
    updated_at = <Date 2020-03-22.06:01:40.448>
    user = 'https://bugs.python.org/OlivierLeMoign'

    bugs.python.org fields:

    activity = <Date 2020-03-22.06:01:40.448>
    actor = 'martin.panter'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Unicode']
    creation = <Date 2016-03-10.11:04:31.918>
    creator = 'Olivier.Le.Moign'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 26527
    keywords = []
    message_count = 3.0
    messages = ['261491', '261492', '364787']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'ezio.melotti', 'martin.panter', 'Olivier.Le.Moign']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'pending'
    superseder = '23434'
    type = 'behavior'
    url = 'https://bugs.python.org/issue26527'
    versions = ['Python 3.5']

    @OlivierLeMoign
    Copy link
    Mannequin Author

    OlivierLeMoign mannequin commented Mar 10, 2016

    According to RFC5987 (http://tools.ietf.org/html/rfc5987), it's possible to use other encoding than ASCII in header fields.
    Specifically in the CGI library, posting files with non-ASCII characters will lead the header to be (for example) filename*=utf-8"xxxxx" which is not recognised:

    l 513

    if 'filename' in pdict:
        self.filename = pdict['filename']
    self._binary_file = self.filename is not None 

    The file will thus be treated as a string.
    The correction isn't too big but being a total newbie, I'm a bit scared to suggest a patch.

    @OlivierLeMoign OlivierLeMoign mannequin added topic-unicode type-bug An unexpected behavior, bug, or error labels Mar 10, 2016
    @OlivierLeMoign
    Copy link
    Mannequin Author

    OlivierLeMoign mannequin commented Mar 10, 2016

    I guess this is fixed by https://pypi.python.org/pypi/rfc6266. Could have looked better, sorry.

    @vadmium
    Copy link
    Member

    vadmium commented Mar 22, 2020

    I’m not an expert on the topic, but it sounds like this might be a duplicate of bpo-23434, which has more discussion.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @kumaraditya303
    Copy link
    Contributor

    Closing as cgi module is deprecated as per PEP 594 and further no improvements or bug fixes will be made to the module.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-unicode type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants