classification
Title: _stringify handles quoted strings incorrectly
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: gauchj, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2018-06-26 18:52 by gauchj, last changed 2018-06-30 10:44 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
0001-improve-escaping-of-quoted-strings.patch gauchj, 2018-06-26 18:52
Pull Requests
URL Status Linked Edit
PR 7986 merged serhiy.storchaka, 2018-06-28 12:00
PR 8018 merged miss-islington, 2018-06-30 06:20
PR 8019 merged miss-islington, 2018-06-30 06:21
PR 8021 merged serhiy.storchaka, 2018-06-30 09:45
Messages (8)
msg320508 - (view) Author: Gauchj (gauchj) Date: 2018-06-26 18:52
_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.
msg320513 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-26 21:30
How did you find this bug?
msg320598 - (view) Author: Gauchj (gauchj) Date: 2018-06-27 16:16
I tried to display entries from the Windows Registry in a TreeView.
msg320663 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-28 12:03
This issue needs more complex fix. PR 7986 adds necessary changes and tests.

Thank you for your report Gauchj.
msg320753 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-30 06:20
New changeset 5bb5bbfca847524bab5f2368bdb48eedf5dba74f by Serhiy Storchaka in branch 'master':
bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
https://github.com/python/cpython/commit/5bb5bbfca847524bab5f2368bdb48eedf5dba74f
msg320756 - (view) Author: miss-islington (miss-islington) Date: 2018-06-30 06:43
New changeset 42ea5226642c2a416b32278914fa4738093298ff by Miss Islington (bot) in branch '3.7':
bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
https://github.com/python/cpython/commit/42ea5226642c2a416b32278914fa4738093298ff
msg320757 - (view) Author: miss-islington (miss-islington) Date: 2018-06-30 06:43
New changeset b2e88fcf63515f8a66759a6fdc75d08a0a440901 by Miss Islington (bot) in branch '3.6':
bpo-33974: Fix passing special characters to ttk widgets. (GH-7986)
https://github.com/python/cpython/commit/b2e88fcf63515f8a66759a6fdc75d08a0a440901
msg320769 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-30 10:34
New changeset 9b84cc8771f52e9340ea5b676da9a15359c723b6 by Serhiy Storchaka in branch '2.7':
[2.7] bpo-33974: Fix passing special characters to ttk widgets. (GH-7986) (GH-8021)
https://github.com/python/cpython/commit/9b84cc8771f52e9340ea5b676da9a15359c723b6
History
Date User Action Args
2018-06-30 10:44:39serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-06-30 10:34:58serhiy.storchakasetmessages: + msg320769
2018-06-30 09:45:19serhiy.storchakasetpull_requests: + pull_request7629
2018-06-30 06:43:25miss-islingtonsetmessages: + msg320757
2018-06-30 06:43:00miss-islingtonsetnosy: + miss-islington
messages: + msg320756
2018-06-30 06:21:38miss-islingtonsetpull_requests: + pull_request7627
2018-06-30 06:20:46miss-islingtonsetpull_requests: + pull_request7626
2018-06-30 06:20:30serhiy.storchakasetmessages: + msg320753
2018-06-28 12:03:46serhiy.storchakasetmessages: + msg320663
versions: + Python 2.7
2018-06-28 12:00:49serhiy.storchakasetstage: patch review
pull_requests: + pull_request7597
2018-06-27 16:16:52gauchjsetmessages: + msg320598
2018-06-26 21:30:00serhiy.storchakasetassignee: serhiy.storchaka

messages: + msg320513
nosy: + serhiy.storchaka
2018-06-26 18:52:55gauchjcreate