← Back to team overview

desktop-packages team mailing list archive

Re: [Bug 1514484] Re: Chromium start-up script doesn't accept argument values with spaces in $CHROMIUM_FLAGS, cause is lack of quotes

 

I agree that it's tricky.

The two solutions I can think of is your idea of an array, and assumption
that the variable should go through two levels of interpretation.

The way that makes current scripts and files still work is the latter. It
would go like this:

If there is a special character in the output, it must be quoted or
escaped. Then, special characters must be escaped again.

So, instead of

CHROMIUM_FLAGS="--foo --bar=one\ two"

it would be

CHROMIUM_FLAGS="--foo --bar=one\\\ two"


So, you should be able to


CHROMIUM_FLAGS="--user-agent=Mozilla\\\ 9.0\\\ not\\\ really
--user-data-dir=/path/with/a\\\ space"


On first interpretation, those backslash-character values are interpreted:
backslashbackslash becomes a backslash, and backslashspace becomes a space.

On second interpretation, the one that runs the program, backslashspace is
a space, but not a space that separates parameters. A literal space.

It's not pretty, I know.


On Tue, Nov 10, 2015 at 8:59 AM, Iuri Chaer <iuri.chaer@xxxxxxxxx>
wrote:

> I noticed that last night =( so sad how often I seem to be surprised by
> how shell expansion works.
>
> Best I could come up with was transform CHROMIUM_FLAGS into an array and
> use "${CHROMIUM_FLAGS[@]}" in the calls instead. Sorry for the failed
> patch attempt.
>
> --
> You received this bug notification because you are a bug assignee.
> https://bugs.launchpad.net/bugs/1514484
>
> Title:
>   Chromium start-up script doesn't accept argument values with spaces in
>   $CHROMIUM_FLAGS, cause is lack of quotes
>
> Status in chromium-browser package in Ubuntu:
>   Confirmed
>
> Bug description:
>   You can't have arguments with spaces inside CHROMIUM_FLAGS, whatever
>   comes after the first space is going to be interpreted as an URL by
>   the actual chromium binary. Easy repro:
>
>   1. Set user's CHROMIUM_FLAGS with an argument containing spaces, eg:
>   $ echo 'CHROMIUM_FLAGS=--user-agent="A B C"' > .chromium-browser.init
>
>   2. Run chromium:
>   $ /usr/bin/chromium-browser
>
>   3. See 2 extra open tabs, one trying to open URL 'B', the other 'C'.
>
>   The cause for this funny behavior is the lack of quotes around
>   $CHROMIUM_FLAGS in the script installed in /usr/bin/chromium-browser
>   -- it calls $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@" by the end of the
>   script. I've tried working around it but couldn't, no amount of
>   escaping and extra quotes seems to help if it's called like that.
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/1514484/+subscriptions
>

-- 
You received this bug notification because you are a member of Desktop
Packages, which is subscribed to chromium-browser in Ubuntu.
https://bugs.launchpad.net/bugs/1514484

Title:
  Chromium start-up script doesn't accept argument values with spaces in
  $CHROMIUM_FLAGS, cause is lack of quotes

Status in chromium-browser package in Ubuntu:
  Confirmed

Bug description:
  You can't have arguments with spaces inside CHROMIUM_FLAGS, whatever
  comes after the first space is going to be interpreted as an URL by
  the actual chromium binary. Easy repro:

  1. Set user's CHROMIUM_FLAGS with an argument containing spaces, eg:
  $ echo 'CHROMIUM_FLAGS=--user-agent="A B C"' > .chromium-browser.init

  2. Run chromium:
  $ /usr/bin/chromium-browser

  3. See 2 extra open tabs, one trying to open URL 'B', the other 'C'.

  The cause for this funny behavior is the lack of quotes around
  $CHROMIUM_FLAGS in the script installed in /usr/bin/chromium-browser
  -- it calls $LIBDIR/$APPNAME $CHROMIUM_FLAGS "$@" by the end of the
  script. I've tried working around it but couldn't, no amount of
  escaping and extra quotes seems to help if it's called like that.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/1514484/+subscriptions


References