Thomasdezeeuw/ini

Quoted values get trimmed, which defeats the purpose of quoting

Closed this issue · 2 comments

The following INI file contains a quoted value:

[Section]
    Foo = "    Bar    "

But after parsing Foo is mapped to "Bar", not to " Bar " -- as I would expect it.

The rationale is simple: since INI format implies trimming of whitespace on both ends of keys and values, quoting is there mostly to preserve that whitespace, if needed.

I suspect the problem is here as the value gets trimmed unconditionally.

You're 100% right, it's stupid that I don't have a test for it.

Working on it now, but it only complicates the code more. But this is evidence for the case that the parseKeyValue function needs to be rewritten.

Thanks for coming up to this so fast! My tests now pass.

As to the parse code... Well, yeah, it could be improved but at least you don't use regular expressions for parsing, so fear not: it's already good enough to be useful!