Bug 216604

Summary: [GTK][WPE] Missing support for multi-word $WEBKIT_MINI_BROWSER_PREFIX
Product: WebKit Reporter: Philippe Normand <pnormand>
Component: Tools / TestsAssignee: Philippe Normand <pnormand>
Status: RESOLVED FIXED    
Severity: Normal CC: aperez, ews-watchlist, glenn, jbedard, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Philippe Normand 2020-09-16 01:23:15 PDT
Currently if this var contains more than one word (like "gdb -args" or "perf record") a python traceback is spewed.
Comment 1 Philippe Normand 2020-09-16 01:25:24 PDT
Created attachment 408904 [details]
Patch
Comment 2 Adrian Perez 2020-09-17 04:37:20 PDT
Comment on attachment 408904 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=408904&action=review

> Tools/Scripts/webkitpy/port/gtk.py:272
> +            command = os.environ["WEBKIT_MINI_BROWSER_PREFIX"].split() + command

Is there any reason to not use shlex.split() here? That would allow for
specifying parameters in the environment variable which have themselves
spaces, by carefully quoting things around. For example:

  WEBKIT_MINI_BROWSER_PREFIX="'/opt/dev tools v1/bin/gdb' --args" \
       run-minibrowser […]

Using a plain str.split() would completely prevent such usage. Not that
I expect quoting of parameters inside the environment variable to be
needed often, but it does not hurt to have our backs covered :)
Comment 3 Philippe Normand 2020-09-17 08:59:34 PDT
In your example would the string with spaces inside need to be quoted again then  to result in:

['"/opt/dev tools v1/bin/gdb"', '--args']

¿
Comment 4 Adrian Perez 2020-09-18 05:23:03 PDT
(In reply to Philippe Normand from comment #3)
> In your example would the string with spaces inside need to be quoted again
> then  to result in:
> 
> ['"/opt/dev tools v1/bin/gdb"', '--args']
> 
> ¿

Note that “shlex.split()” uses the same parsing rules as the Bourne shell,
so it results in the correct thing:

>>> import shlex
>>> shlex.split('"/opt/dev tools v1/bin/gdb" --args')
['/opt/dev tools v1/bin/gdb', '--args']
>>> shlex.split('"/opt/dev tools v1/bin/gdb" --args')
['/opt/dev tools v1/bin/gdb', '--args']
>>> 

;-)
Comment 5 Philippe Normand 2020-09-19 07:00:13 PDT
Created attachment 409200 [details]
Patch
Comment 6 EWS 2020-09-21 11:59:02 PDT
Committed r267350: <https://trac.webkit.org/changeset/267350>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 409200 [details].
Comment 7 Radar WebKit Bug Importer 2020-09-21 12:26:23 PDT
<rdar://problem/69319805>