File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ const formatValue = (v: string): string => {
7373 if ( ! q1 && ! q2 && ! q3 && ! s ) return v
7474 if ( ! q1 ) return `${ Q1 } ${ v } ${ Q1 } `
7575 if ( ! q2 ) return `${ Q2 } ${ v } ${ Q2 } `
76+ if ( parse ( `V=${ Q3 } ${ v } ${ Q3 } ` ) . V !== v ) throw new Error ( `Invalid value: ${ v } ` )
7677 return `${ Q3 } ${ v } ${ Q3 } `
7778}
7879
Original file line number Diff line number Diff line change @@ -71,6 +71,14 @@ JSONSTR='{"foo": "b a r"}'`
7171)
7272 } )
7373
74+ test ( 'stringify checks invalid (imbalanced quote) values' , ( ) => {
75+ const V1 = "en_US\"'`\nBASH_ENV=$(id 1>&2)\nx=`"
76+ const V2 = 'foo=\'bar\'\nbaz=\\`"qux\\`\"\"'
77+
78+ assert . throws ( ( ) => stringify ( { V1 } ) )
79+ assert . throws ( ( ) => stringify ( { V2 } ) )
80+ } )
81+
7482 test ( 'accepts buffer input' , ( ) => {
7583 const str = 'FOO=BAR\r\nBAz=QUZ'
7684 const env = {
You can’t perform that action at this time.
0 commit comments