npm / ini

An ini parser/serializer in JavaScript
ISC License
770 stars 206 forks source link

error while parsing semicolons #42

Open kixorz opened 9 years ago

kixorz commented 9 years ago

Ini spec only allows semicolons to be interpreted as comments when they are in the beginning of the line. ; comment I'm experiencing bug when parsing the following keypair: key=value;value;value value;value;value should be interpreted as a string and instead it's parsed only as value and rest is ignored.

Thanks for considering a fix!

themightychris commented 8 years ago

There doesn't seem to be any "official" spec just what's popular in implementations... and git is one example that does permit same-line comments: https://git-scm.com/docs/git-config

Maybe an extra parse option is called for?

kixorz commented 8 years ago

Extra parsing option would work!

rijnhard commented 8 years ago

so funny enough I had a similar need but for Zend booleans, I already have a pr with tests, but @isaacs hasn't commented yet. https://github.com/npm/ini/pull/50

It would be easy to add another decode filter, but may take some screwing around since it changes things a bit

digitalica commented 8 years ago

i found this issue too. I have values containig html entities. Worked fine in Python... And it was also fixed in PHP (https://bugs.php.net/bug.php?id=51094). Extra parsing option could fix this.

vintprox commented 4 years ago

2k20 still needed thanks to 3dx and such - putting path arrays with semicolons in values... For those who don't want to waste time searching solution: https://www.npmjs.com/package/js-ini

yeroca commented 1 year ago

I have the same issue with ; and # both. The WinAPI does not allow comments in the key portion, so these characters are treated as part of the key's value. See https://en.wikipedia.org/wiki/INI_file#Comments_2 for reference.

As stated above, parsing of ; and # in keys should be an option, not mandatory. I ended up forking the code for this reason, and ripped out the key comment processing bits.

(I also converted it to Typescript for easier inclusion in a React-TS app)