fix(parsing): handle edge case of blank strings as keys - #1
Merged
Conversation
Owner
|
Did you test this against typical input that previously parsed fine? |
Contributor
Author
|
I did yes, I tested it against some test cases I found in other libs, for example here and the other binarykv's I'm using. Test script for old data (from the above link): const BinaryKVParser = require('binarykvparser');
var str = 'ADUAAmJpbGxpbmd0eXBlAAMAAAACY2hhbmdlbnVtYmVyAA9qGwACY29kZWNsYXNzAAEAAAACZ2FtZWNvZGUAAwAAAAJsaWNlbnNldHlwZQABAAAAAnBhY2thZ2VpZAAFAAAAAnN0YXR1cwAAAAAAAnRlcnJpdG9yeWNvZGUAAAAAAABleHRlbmRlZAACRGV2Q29tcAABAAAAAk9uUHVyY2hhc2VHcmFudEd1ZXN0UGFzc1BhY2thZ2UxACQBAAAIAGFwcGlkcwACMAAKAAAAAjEAFAAAAAIyAB4AAAACMwAoAAAAAjQAMgAAAAI1ADwAAAACNgBGAAAAAjcAggAAAAI4ANMAAAACOQDXAAAAAjEwANoAAAACMTEA3AAAAAIxMgDwAAAAAjEzAEABAAACMTQAVAEAAAIxNQDe4QMACABkZXBvdGlkcwACMAAAAAAAAjEA3QAAAAIyAPEAAAACMwAHAQAAAjQAVQEAAAI1AN/hAwAIAEFwcEl0ZW1zAAgICA==';
var buf = new Buffer(str, 'base64')'
BinaryKVParser.parse(buf);Should output: { '5':
{ billingtype: 3,
changenumber: 1796623,
codeclass: 1,
gamecode: 3,
licensetype: 1,
packageid: 5,
status: 0,
territorycode: 0,
extended: { DevComp: 1, OnPurchaseGrantGuestPassPackage1: 292 },
appids: [ 10, 20, 30, 40, 50, 60, 70, 130, 211, 215, 218, 220, 240, 320, 340, 254430 ],
depotids: [ 0, 221, 241, 263, 341, 254431 ],
AppItems: [] } } |
Owner
|
Perfect. I'll go ahead and publish this then. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes edge case of blank strings being keys. Not sure why this would ever happen, but heres some test data.
meta.txt
Edit:
Output of this specific case before:
Expected output
uids is still not parsed properly, but seems to be consistent with other parsers (i.e. https://github.com/ValvePython/vdf and https://github.com/SteamRE/SteamKit/blob/master/SteamKit2/SteamKit2/Types/KeyValue.cs#L850