This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 999770 - [origin_broker_86] User Env variable's value still cannot support special chars like '%' , ';'
[origin_broker_86] User Env variable's value still cannot support special cha...
Status: CLOSED NOTABUG
Product: OpenShift Online
Classification: Red Hat
Component: Master (Show other bugs)
2.x
All All
medium Severity low
: ---
: ---
Assigned To: Ben Parees
libra bugs
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-08-22 01:34 EDT by zhaozhanqi
Modified: 2015-05-14 20:55 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-11-15 16:17:17 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description zhaozhanqi 2013-08-22 01:34:54 EDT
Description of problem:
if user env variable's value contain like '|',';' etc , this variable will be set to blank. 

Version-Release number of selected component (if applicable):
devenv_3683
devenv_stage_448

How reproducible:
always

Steps to Reproduce:
1. creat one app 
2. add one env variable with special charcter(for example '|') for this app
   curl -k -H 'Accept: application/xml' --user zzhao@redhat.com:redhat https://$instance/broker/rest/applications/479428171624072284733440/environment-variables -X POST -d name=special -d value=|/usr/bin/lesspipe.sh

3. check its env
   rhc ssh app --gear env|grep special

Actual results:
 after step 2, it will not give a response result.
 curl -k -H 'Accept: application/xml' --user zzhao@redhat.com:redhat https://$instance/broker/rest/applications/479428171624072284733440/environment-variables -X POST -d name=special -d value=|/usr/bin/lesspipe.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
103  2248  102  2248    0    19   1175      9  0:00:01  0:00:01 --:--:--  2591


[zqzhao@dhcp-13-222 .openshift]$ rhc ssh zqphp --gear env|grep special
special=


Expected results:
step 2: should be give a result like 'Added environment variable 'special' to application zqphp
step 3: special=|/usr/bin/lesspipe.sh

Additional info:
Comment 1 Lili Nader 2013-08-22 02:42:01 EDT
Ravi, let me know if you need help with bug fixes
Comment 2 Ravi Sankar 2013-08-22 14:00:02 EDT
This is expected behavior.
Step-2 is interpreted by bash shell as
(a) curl -k -H 'Accept: application/xml' --user zzhao@redhat.com:redhat https://$instance/broker/rest/applications/479428171624072284733440/environment-variables -X POST -d name=special -d value=
(b) Output of (a) will be passed to /usr/bin/lesspipe.sh because of '|'

What you might have intended was to do this:
curl -k -H 'Accept: application/xml' --user zzhao@redhat.com:redhat https://$instance/broker/rest/applications/479428171624072284733440/environment-variables -X POST -d name=special -d value='|/usr/bin/lesspipe.sh' => this works.

Note: single quotes ('') was missing for the value param.
Comment 4 zhaozhanqi 2013-08-22 22:31:29 EDT
RE-open this bug, ';' '%' still cannot be parsed 
 
1)curl -k -H 'Accept: application/xml' --user zzhao@redhat.com:redhat https://$instance/broker/rest/applications/8ab67c8c0b9811e3928e22000ab227cc/environment-variables/foo -X PUT  -d value='rs=0:di=01;34:ln=01'

$ rhc ssh zqphp --gear env |grep foo
foo=rs=0:di=01

2)curl -k -H 'Accept: application/xml' --user zzhao@redhat.com:redhat https://$instance/broker/rest/applications/8ab67c8c0b9811e3928e22000ab227cc/environment-variables/foo -X PUT  -d value='|/usr/bin/lesspipe.sh %s'

it will return errors '<h1>
  ArgumentError
    in EnvironmentVariablesController#update
</h1>
<pre>invalid %-encoding (|/usr/bin/lesspipe.sh %s)</pre>'

FIY:
the following env variable are got from 'env', so we need to support this situation.

LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;0
LESSOPEN=|/usr/bin/lesspipe.sh %s
Comment 5 Ben Parees 2013-11-15 16:15:29 EST
; and % are special characters in html form posting (which is the format you're using with the -d curl commands) so you'd need to escape them, eg:

curl -k -H 'Accept: application/xml' --user test:test https://ec2-54-205-123-138.compute-1.amazonaws.com/broker/rest/domain/test/application/jbossews/environment-variables -X POST -d name=foo8 -d value='bar%3B'

yields:
rhc ssh jbossews --gear env | grep foo8
foo8=bar;

and
curl -k -H 'Accept: application/xml' --user test:test https://ec2-54-205-123-138.compute-1.amazonaws.com/broker/rest/domain/test/application/jbossews/environment-variables -X POST -d name=foo9 -d value='bar%25'

yields
rhc ssh jbossews --gear env | grep foo9
foo9=bar%

Note that I also tested the rhc commands directly and they handle the escaping for you (well they appear to use json so html form encoding is not an issue):

rhc env set test=test%test --app jbossews
Setting environment variable(s) ... done
rhc env show test --app jbossews
test=test%test

# note in this case i had to quote the value to avoid the shell processing the ;
rhc env set test='test;test' --app jbossews
Setting environment variable(s) ... done
rhc env show test --app jbossews
test=test;test

Note You need to log in before you can comment on or make changes to this bug.