node-steam / vdf

Module to convert Valve's KeyValue format to JSON and back
https://node-steam.github.io/vdf/
MIT License
34 stars 3 forks source link

Backslash escaping is not handled #14

Open dominik-korsa opened 2 years ago

dominik-korsa commented 2 years ago

The following is snippet is from C:\Program Files (x86)\Steam\steamapps\libraryfolders.vdf:

"libraryfolders"
{
    "contentstatsid"        "4102335621006428237"
    "0"
    {
        "path"      "C:\\Program Files (x86)\\Steam"
        // ...
    }
    "1"
    {
        "path"      "D:\\SteamLibrary"
        // ...
    }
}

As you can see, there is a path key and it's value escapes the \ character. Your library parses them as C:\\Program Files (x86)\\Steam - the backslash incorrectly appears twice If I then do

const result = VDF.parse(/* ... */);
console.log(JSON.stringify(result.libraryfolders.0.path));

"C:\\\\Program Files (x86)\\\\Steam" gets logged

dominik-korsa commented 2 years ago

From the docs:

Allowed Escape sequences are \n, \t, \\, and \".