Skip to content

[bug] Unable to read shortcuts.vdf #7

Description

@WillsterJohnson

Steps to reproduce

  1. Identify your user id.
  2. Run the command shown below these steps
  3. Observe syntax error

Command (replace <your-id-here> with your id):

npm init && npm i vdf-parser && echo "require(\"vdf-parser\").parse(require(\"node:fs\").readFileSync(\"$HOME/.local/share/Steam/userdata/<your-id-here>/config/shortcuts.vdf\",\"utf-8\"))" | node

As JS file:

const fs = require("node:fs");
const vdf = require("vdf-parser");

vdf.parse(fs.readFileSync("/home/<your-user-name>/.local/share/Steam/userdata/<your-id-here>/config/shortcuts.vdf","utf-8"))

Output:

/.../node_modules/.pnpm/vdf-parser@1.2.1/node_modules/vdf-parser/main.js:114
                throw new SyntaxError("VDF.parse: invalid syntax on line " + (i+1) + ":\n" + line);
                ^

SyntaxError: VDF.parse: invalid syntax on line 1:
shortcuts0appid�B��AppNameMO2 -SkyrimExe"/<path-here>/steamapps/compatdata/489830/pfx/drive_c/Modding/MO2/ModOrganizer.exe"StartDir
    at Object.parse (/.../node_modules/.pnpm/vdf-parser@1.2.1/node_modules/vdf-parser/main.js:114:23)
    at [stdin]:1:23
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:307:38)
    at node:internal/process/execution:79:19
    at [stdin]-wrapper:6:22
    at evalScript (node:internal/process/execution:78:60)
    at node:internal/main/eval_stdin:30:5
    at Socket.<anonymous> (node:internal/process/execution:195:5)
    at Socket.emit (node:events:525:35)

Node.js v18.16.0

Additional info

The encoding is listed as data for this file. None of the available encodings in fs.readFileSync alter the behavior.

I have not manually modified this file other than the intended use of adding a non-steam game via the steam app.

Copy-pasting the file content into a string does not work due to octal sequences, escaping them returns to the initial error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions