davidnussio / vscode-jq-playground

Visual Code Studio jq playground
https://marketplace.visualstudio.com/items?itemName=davidnussio.vscode-jq-playground
MIT License
46 stars 8 forks source link

Extension output contains additional commas in random places, resulting in malformed JSON #61

Closed mz8i closed 4 years ago

mz8i commented 4 years ago

Large output contains additional commas, resulting in malformed JSON.

The cause for this which I have identified is incorrect assembling of the command line stdout:

on line https://github.com/davidnussio/vscode-jq-playground/blob/8f25f3afb22475332b1168daa4a76d32749c55aa/src/command-line.ts#L156

result.stdout (which is an array of buffers) is passed to res, but later on, in lines https://github.com/davidnussio/vscode-jq-playground/blob/8f25f3afb22475332b1168daa4a76d32749c55aa/src/extension.ts#L367 or https://github.com/davidnussio/vscode-jq-playground/blob/8f25f3afb22475332b1168daa4a76d32749c55aa/src/extension.ts#L371 that array is passed to bufferToString which simply calls .toString() on the argument. This results in the array elements being joined by commas. This would not be visible for short test outputs as the array would usually only have one element.

Unfortunately I cannot share the file I am working on but it should be easily reproduced on any randomly-generated JSON that is sufficiently large (input size ~30MB, output size ~300KB).

Thanks for the extension, it's really great, but would appreciate fixing this as it renders the whole thing broken for large files.

davidnussio commented 4 years ago

Thanks for the detailed analysis, I released the fix.