Bug 216604 - [GTK][WPE] Missing support for multi-word $WEBKIT_MINI_BROWSER_PREFIX
Summary: [GTK][WPE] Missing support for multi-word $WEBKIT_MINI_BROWSER_PREFIX
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Philippe Normand
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-16 01:23 PDT by Philippe Normand
Modified: 2020-09-21 12:26 PDT (History)
5 users (show)

See Also:


Attachments
Patch (2.48 KB, patch)
2020-09-16 01:25 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff
Patch (2.89 KB, patch)
2020-09-19 07:00 PDT, Philippe Normand
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>