Dream Daemon does not deal properly with key collision in invalid JSON objects. Note that this requires the JSON to be invalid.
Numbered Steps to Reproduce Problem:
1. Decode a JSON object with key collision such as {"key1": "value1", "key1": "value2"}
2. Notice that you now have duplicate entries in the list(the key will show up twice while iterating)
Code Snippet (if applicable) to Reproduce Problem:
world.log << json_encode(json_decode(@|{"key1": "value1", "key1": "value2"}|))
//Output: {"key1": "value2", "key1": "value2"}
//Expected output(one of):
// Invalid JSON runtime error
// {"key1": "value1"}
// {"key1": "value2"}
var/list/L = json_decode(@|{"key1": "value1", "key1": "value2"}|)
for(var/i in L)
world.log << "[i]|[L[i]]"
//Output: key1|value2 \n key1|value2
//Expected output(one of):
// Invalid JSON runtime error
// key1|value1
// key1|value2
Expected Results:
Either:
-The list contains a single entry with the value of the last entry
-The list contains a single entry with the value of the first entry
-A runtime error created by json_decode()
Actual Results:
The list contains two entries of the same key which have the value of the last entry
Does the problem occur:
Every time? Or how often? Every time
In other games? N/A
In other user accounts? Unknown
On other computers? Yes
When does the problem NOT occur?
When theres no key collision
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Tested on 514.1554 and 513.1542, issue existed in both
Workarounds:
Validating that there are no conflicting keys after running json_decode if the JSON is from untrusted user input