ValvePython / vdf

📜 Package for working with Valve's text and binary KeyValue format
https://pypi.org/project/vdf/
MIT License
165 stars 30 forks source link

Nested groups with duplicate keys trivially do not work, even with VDFDict #59

Open GiovanH opened 6 months ago

GiovanH commented 6 months ago

Input file demo.vdf:

"controller_mappings"
{
    "group"
    {
        "id"        "0"
    }
    "group"
    {
        "id"        "1"
    }
}

Test script:

import vdf
with open("demo.vdf") as fp:
    v = vdf.load(fp, mapper=vdf.VDFDict)
    print(type(v))
    print(type(v['controller_mappings']))
    print(vdf.dumps(v, pretty=True))

Expected output: (demo.vdf)

Actual output:

<class 'vdf.vdict.VDFDict'>
<class 'vdf.vdict.VDFDict'>
"controller_mappings"
{
        "group"
        {
                "id" "0"
                "id" "1"
        }
}

Not only is this incorrect, but no error is thrown: the resulting data structure is silently malformed and passed along.