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

_stringify handles quoted strings incorrectly #78155

Closed
gauchj mannequin opened this issue Jun 26, 2018 · 8 comments
Closed

_stringify handles quoted strings incorrectly #78155

gauchj mannequin opened this issue Jun 26, 2018 · 8 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@gauchj
Copy link
Mannequin

gauchj mannequin commented Jun 26, 2018

BPO 33974
Nosy @serhiy-storchaka, @miss-islington, @gauchj
PRs
  • bpo-33974: Fix passing special characters to ttk widgets. #7986
  • [3.7] bpo-33974: Fix passing special characters to ttk widgets. (GH-7986) #8018
  • [3.6] bpo-33974: Fix passing special characters to ttk widgets. (GH-7986) #8019
  • [2.7] bpo-33974: Fix passing special characters to ttk widgets. (GH-7986) #8021
  • Files
  • 0001-improve-escaping-of-quoted-strings.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/serhiy-storchaka'
    closed_at = <Date 2018-06-30.10:44:39.187>
    created_at = <Date 2018-06-26.18:52:55.319>
    labels = ['3.7', '3.8', 'type-bug', 'expert-tkinter']
    title = '_stringify handles quoted strings incorrectly'
    updated_at = <Date 2018-06-30.10:44:39.187>
    user = 'https://github.com/gauchj'

    bugs.python.org fields:

    activity = <Date 2018-06-30.10:44:39.187>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2018-06-30.10:44:39.187>
    closer = 'serhiy.storchaka'
    components = ['Tkinter']
    creation = <Date 2018-06-26.18:52:55.319>
    creator = 'gauchj'
    dependencies = []
    files = ['47654']
    hgrepos = []
    issue_num = 33974
    keywords = ['patch']
    message_count = 8.0
    messages = ['320508', '320513', '320598', '320663', '320753', '320756', '320757', '320769']
    nosy_count = 3.0
    nosy_names = ['serhiy.storchaka', 'miss-islington', 'gauchj']
    pr_nums = ['7986', '8018', '8019', '8021']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue33974'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @gauchj
    Copy link
    Mannequin Author

    gauchj mannequin commented Jun 26, 2018

    _stringify escapes special characters so they can be processed by tcl/tk. To that end, two different escaping techniques are implemented: put a backslash in front of every special character or put the entire string in curly braces.

    However, a string like the following one:

    '"C:\\Windows\\System32\\notepad.exe" "afile.txt"'

    will be incorrectly escaped to

    '"C:\\\\Windows\\\\System32\\\\notepad.exe"\\ "afile.txt"'

    Tcl/TK will interpret this as a quoted string, but with a backslash after it (the one escaping the space between the quoted strings), throwing this exception:
    TclError('list element in quotes followed by "\\" instead of space',)

    The attached patch escapes this to

    '{"C:\\\\Windows\\\\System32\\\\notepad.exe" "afile.txt"}'

    I am not 100% sure that this is correct since double backslashes seem to be displayed now.

    @gauchj gauchj mannequin added 3.7 (EOL) end of life 3.8 only security fixes topic-tkinter type-bug An unexpected behavior, bug, or error labels Jun 26, 2018
    @serhiy-storchaka
    Copy link
    Member

    How did you find this bug?

    @serhiy-storchaka serhiy-storchaka self-assigned this Jun 26, 2018
    @gauchj
    Copy link
    Mannequin Author

    gauchj mannequin commented Jun 27, 2018

    I tried to display entries from the Windows Registry in a TreeView.

    @serhiy-storchaka
    Copy link
    Member

    This issue needs more complex fix. PR 7986 adds necessary changes and tests.

    Thank you for your report Gauchj.

    @serhiy-storchaka
    Copy link
    Member

    New changeset 5bb5bbf by Serhiy Storchaka in branch 'master':
    bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
    5bb5bbf

    @miss-islington
    Copy link
    Contributor

    New changeset 42ea522 by Miss Islington (bot) in branch '3.7':
    bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
    42ea522

    @miss-islington
    Copy link
    Contributor

    New changeset b2e88fc by Miss Islington (bot) in branch '3.6':
    bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
    b2e88fc

    @serhiy-storchaka
    Copy link
    Member

    New changeset 9b84cc8 by Serhiy Storchaka in branch '2.7':
    [2.7] bpo-33974: Fix passing special characters to ttk widgets. (GH-7986) (GH-8021)
    9b84cc8

    @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
    3.7 (EOL) end of life 3.8 only security fixes topic-tkinter type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants