|
103 | 103 | const expected = `email,tiers\r\[email protected],Bronze Level`;
|
104 | 104 | assert.equal(result, expected);
|
105 | 105 | });
|
| 106 | + |
| 107 | + it('escapes fields starting with CSV injection characters', async function () { |
| 108 | + const json = [{ |
| 109 | + |
| 110 | + name: '=1+2', |
| 111 | + note: 'Early supporter' |
| 112 | + }]; |
| 113 | + |
| 114 | + const result = unparse(json); |
| 115 | + assert.ok(result); |
| 116 | + |
| 117 | + const expected = `id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers\r\n,[email protected],"'=1+2",Early supporter,,,,,,,`; |
| 118 | + assert.equal(result, expected); |
| 119 | + }); |
| 120 | + |
| 121 | + it('escapes fields with CSV injection characters and quotes', async function () { |
| 122 | + const json = [{ |
| 123 | + |
| 124 | + name: `=1+2'" `, |
| 125 | + note: 'Early supporter' |
| 126 | + }]; |
| 127 | + |
| 128 | + const result = unparse(json); |
| 129 | + assert.ok(result); |
| 130 | + |
| 131 | + const expected = `id,email,name,note,subscribed_to_emails,complimentary_plan,stripe_customer_id,created_at,deleted_at,labels,tiers\r\n,[email protected],"'=1+2'"" ",Early supporter,,,,,,,`; |
| 132 | + assert.equal(result, expected); |
| 133 | + }); |
106 | 134 | });
|
0 commit comments