npm / ini

An ini parser/serializer in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lists of quoted strings containing semicolons are not being parsed properly

GreenGremlin opened this issue · 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

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\\;')));

This is similar to #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.