From 0cc14f65a2d7ccb39b1cbb8dffae08f152da4139 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Mon, 22 Feb 2021 11:44:10 +0530 Subject: [PATCH] Do not quote ini values with error constants --- __tests__/utils.test.ts | 20 ++++++++++++++------ dist/index.js | 2 +- src/utils.ts | 2 +- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 43337465..3eab1960 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -97,12 +97,9 @@ describe('Utils tests', () => { const runner_dir: string = process.env['RUNNER_TOOL_CACHE'] || ''; const script_path: string = path.join(runner_dir, 'test.sh'); await utils.writeScript('test.sh', testString); - await fs.readFile( - script_path, - function (error: Error | null, data: Buffer) { - expect(testString).toBe(data.toString()); - } - ); + fs.readFile(script_path, function (error: Error | null, data: Buffer) { + expect(testString).toBe(data.toString()); + }); await cleanup(script_path); }); @@ -135,6 +132,17 @@ describe('Utils tests', () => { 'b=3, 4', 'c=5' ]); + expect(await utils.CSVArray('\'a=1,2\', "b=3, 4", c=5, d=~e~')).toEqual([ + 'a=1,2', + 'b=3, 4', + 'c=5', + "d='~e~'" + ]); + expect(await utils.CSVArray('a=\'1,2\', b="3, 4", c=5')).toEqual([ + 'a=1,2', + 'b=3, 4', + 'c=5' + ]); expect(await utils.CSVArray('')).toEqual([]); expect(await utils.CSVArray(' ')).toEqual([]); }); diff --git a/dist/index.js b/dist/index.js index e1272644..142be1b8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1285,7 +1285,7 @@ async function CSVArray(values_csv) { return value .trim() .replace(/^["']|["']$|(?<==)["']/g, '') - .replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'"); + .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'"); }) .filter(Boolean); } diff --git a/src/utils.ts b/src/utils.ts index c88f339b..8f74ccf8 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -274,7 +274,7 @@ export async function CSVArray(values_csv: string): Promise> { return value .trim() .replace(/^["']|["']$|(?<==)["']/g, '') - .replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'"); + .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'"); }) .filter(Boolean); }