ini icon indicating copy to clipboard operation
ini copied to clipboard

Lists of quoted strings containing semicolons are not being parsed properly

Open GreenGremlin opened this issue 7 years ago • 2 comments

Here's a simple reproduction of this Issue:

const iniParser = require('ini');

console.log(iniParser.parse('values=["foo; bar"]'));

Actual result:

Semicolon's in a quoted string in a list are parsed as a comment.

{ values: '["foo' }

Expected result:

Semicolon's in a quoted string should not be parsed as a comment.

{ values: ['foo; bar'] }
  • ini version: 1.3.5
  • node version: 8.9.4

GreenGremlin avatar Jul 30 '18 22:07 GreenGremlin

Honestly, I'm not too familiar with the ini format. Looking around, it sounds like the MS implementation does not support end of line comments, but other ini implementations do support it. It would be nice if this library had the option to disable end of line comments.

In the meantime, it looks like I can get by using a regex to escape semicolon's that are not at the start of a line.

const iniStr = 'values=["foo; bar"]';
console.log(iniParser.parse(iniStr.replace(/([\S] *);/g, '$1\\;')));

GreenGremlin avatar Jul 31 '18 19:07 GreenGremlin

This is similar to https://github.com/npm/ini/issues/142. You can try my fork, ini-win, which aims to be more compatible with the way Windows handles ini files. Windows only supports whole line comments, and so does my fork, so it fixes this issue.

m417z avatar Mar 17 '22 21:03 m417z