From 1686147b24d176ca416781e2af1576dc3ed05ef0 Mon Sep 17 00:00:00 2001 From: Shivam Mathur Date: Thu, 4 Feb 2021 13:01:05 +0530 Subject: [PATCH] Do not quote ini values with error constants --- __tests__/utils.test.ts | 3 +++ dist/index.js | 2 +- src/utils.ts | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 9e7b4be7..7eaec679 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -136,6 +136,9 @@ describe('Utils tests', () => { 'b=3, 4', 'c=5' ]); + expect( + await utils.CSVArray('a=E_ALL, b=E_ALL & ~ E_ALL, c="E_ALL", d=\'E_ALL\'') + ).toEqual(['a=E_ALL', 'b=E_ALL & ~ E_ALL', 'c=E_ALL', 'd=E_ALL']); expect(await utils.CSVArray('')).toEqual([]); expect(await utils.CSVArray(' ')).toEqual([]); }); diff --git a/dist/index.js b/dist/index.js index e2190853..75cbe17e 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 5391cc59..cb3af9c0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -273,7 +273,7 @@ export async function CSVArray(values_csv: string): Promise> { return value .trim() .replace(/^["']|["']$|(?<==)["']/g, '') - .replace(/=(.*[?{}|&~![()^]+.*)/, "='$1'"); + .replace(/=(((?!E_).)*[?{}|&~![()^]+((?!E_).)+)/, "='$1'"); }) .filter(Boolean); }