zonyitoo / rust-ini

INI file parser in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot correctly parse value with partial quoting

blahgeek opened this issue · comments

e.g.

[Section]
A="quote" arg0
B=b

The parsed value for key A is quote (quote arg0 or "quote" arg0 is expected), and the parsed value for key B is empty (b is expected).

commented

I think the expected result is quote arg0.

commented

Quick fix. Is that work for you?

Hi @zonyitoo , thanks for the quick reply and fixing!

Now that I've thought about it, the "quote" arg0 parsing result makes more sense to me, especially for linux .desktop files, like:

[Desktop Entry]
Exec = "/path/to/exe with space" arg

The value for Exec key should be "/path/to/exe with space" arg, and it's the shell's responsibility to further parse it into ["/path/to/exe with space", "arg"]. It's documented in the Desktop Entry Specification. Though I'm not sure about general INI file format specification.

Maybe add an option to support both?

commented

Basic INI file format does not support " and '. Everything is a string.
Maybe I can add an option to disable quoting support?

Ok that would be great.

commented

@blahgeek Please test the latest commit.

It works great for me, thanks for the work!

One little thing, the ParseOption type is now under namespace ini::ini, maybe pub use it in namespace ini?

commented

Of course. I will do it tonight.

commented

It should work now.

commented

Will be published in v0.11.0