Skip to content

dictionary not sorted #13

Description

@derrickoswald

According to the BitTorrent specification dictionaries need to be sorted:

"Dictionaries are encoded as a 'd' followed by a list of alternating keys and their corresponding values followed by an 'e'. For example, d3:cow3:moo4:spam4:eggse corresponds to {'cow': 'moo', 'spam': 'eggs'} and d4:spaml1:a1:bee corresponds to {'spam': ['a', 'b']}. Keys must be strings and appear in sorted order (sorted as raw strings, not alphanumerics)."

However, node-bencode simply converts object properties as found. Here is the test case:

var data = {
string: 'Hello World',
integer: 12345,
}
var result = bencode.encode( data )

produces:
d6:string11:Hello World7:integeri12345ee

should be:
d7:integeri12345e6:string11:Hello Worlde

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions