npm / ini

An ini parser/serializer in JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Encode values without quoting (unsafe encoding)

schroffl opened this issue · comments

When encoding a Base64 String with padding, the parser quotes it. But since another parser does not understand these quotes, it fails to decode the string.

let buf = new Buffer(16), // Buffer filled with random bytes
    section = ini.parse('[section]\nkey=' + buf.toString());

console.log(section); // { section: { key: 'UPIvqf0AAABA5i+p/QAAAA==' } }
console.log(encode(section)); // key="4EQ8rlYAAAAQlTWuVgAAAA=="

Hence I suggest to add an option to allow for unsafe encoding.

I would like to have the option too, since safe breaks aws credentials file

You can try my fork, ini-win, which aims to be more compatible with the way Windows handles ini files. It quotes the value only in two cases, if the value has leading or trailing whitespace, or if the value is already quoted.

You can try my fork, ini-win, which aims to be more compatible with the way Windows handles ini files. It quotes the value only in two cases, if the value has leading or trailing whitespace, or if the value is already quoted.

Thanks for your fork!