SamboyCoding / Tomlet

Zero-Dependency, model-based TOML De/Serializer for .NET
MIT License
155 stars 29 forks source link

fix: Serializing dictionary with ', ", . in key & #37 #38

Open ITR13 opened 8 months ago

ITR13 commented 8 months ago

Fixes issue where GetTopLevelAndSubKeys splits a key when serializing. Adds test to handle new cases. Does not test cases with mixed " and ' due to issue explained in #37.

coveralls commented 8 months ago

Coverage Status

coverage: 92.835% (+0.9%) from 91.909% when pulling 9061871a70b934fc3b425100ad899da92af6c48b on ITR13:master into acbaa752568dc1557c90834cf538e9dc1e0025c6 on SamboyCoding:master.

ITR13 commented 8 months ago

Easiest way to understand the issue is the test StringTests.EscapedQuotesInAKeyAreValid: The key string used there is "\"a.b\"", which when passed into StringTests.EscapedQuotesInAKeyAreValid would correctly only create a single key The problem is that the parser pre-unescapes the key to "a.b", which breaks the whole thing. It might be possible to have it not unescape it, and instead unescape it later, but I don't know it this breaks other code.

The parser is also unable to parse strings in the form "a.b".c or "\"a.b\"".c, which both are allowed in the toml specification. For that I can imagine two possible fixes, but I haven't looked at the parser yet and would not know of any other issues:

levicki commented 6 months ago

This fix seems to be related to the issue I reported. Is there any ETA for it?