Allow newlines to be part of environment variables

We were not allowing newlines previously by virtue of the regex not
allowing them. The docker daemon and supervisor handling code both
support them, so we allow them in the parsing code too.

Change-type: patch
Signed-off-by: Cameron Diver <cameron@balena.io>
This commit is contained in:
Cameron Diver 2019-02-11 14:53:25 +00:00
parent 6bf008cc85
commit 49dbaaba12
No known key found for this signature in database
GPG Key ID: 49690ED87032539F
2 changed files with 3 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import { EnvVarObject } from './types';
export function envArrayToObject(env: string[]): EnvVarObject {
const toPair = (keyVal: string) => {
const m = keyVal.match(/^([^=]+)=(.*)$/);
const m = keyVal.match(/^([^=]+)=([^]*)$/);
if (m == null) {
console.log(
`WARNING: Could not correctly parse env var ${keyVal}. ` +

View File

@ -43,9 +43,11 @@ describe 'conversions', ->
'key2=test\ntest',
'key3=test ',
'key4= test '
'key5=test\r\ntest',
])).to.deep.equal({
key1: ' test',
key2: 'test\ntest',
key3: 'test ',
key4: ' test ',
key5: 'test\r\ntest'
})