-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
does bencode dictionary allow duplicated keys? #153
Comments
apparently dictionary should not have duplicated keys, otherwise after sorting it will have different encoding result for same content. for example, |
bencode itself has no concept of encoding, that's an artifact of the language you're using. BEP 52 clarifies this. |
that's why I'm asking, it doesn't clarify if |
encoding itself is a concept of programing language, but bencode content itself is not. |
What I mean is the type distinction between string and binary is something that exists in the language. If that didn't exist you couldn't have duplicates there either. But yes, the word "unique" could be inserted somewhere. |
This problem here is just like url query, it's also a key-value pair, but allow duplicated keys. just being key-value pair is not enough. |
The spec was written by python developers (python 2 back then) who I figure understood dictionary to mean unique keys. And yes, other implementations also require unique keys. |
thanks for your clarification, I just send a PR to document this, hope it can get merged. (I don't know python 2 well but it has a unicode type I think?) |
Document that duplicated keys in bencode directory are not allowed bittorrent#153 here d3:keyi1e3:keyi2ee or d3:keyi2e3:keyi1ee are same directory but can have different bencode content. This may confusing info_hash generator. save torrent will result into different info_hash bittorrent#154
for example:
d3:keyi1e3:keyi2ee
for{"key": 1, b"key": 2}
(python)The text was updated successfully, but these errors were encountered: