View Issue Details
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0009549||New issues||Multi Theft Auto : San Andreas||public||2017-02-16 13:37||2017-02-27 15:20|
|Summary||0009549: Erroneous fromJSON parsing|
Check the example below. "^T^0" is parsed as a table for some reason which recently broke one of our resources. Replacing "^T^0" with "^T^1" returns nil on the other hand. Changing the string to anything other than "^T^0^" or similar fixes the problem.
|Steps To Reproduce|
srun tb = fromJSON('[ [ 2251, "^The^ Winners^", "^T^0", 2, 0, 0, 0, [ 102, 153, 204 ], "WRITE SOMENTHING YOU ABOUT\n\n" ] ]')
Command results: table: 0x653aa35a53c0 [table]
srun tb = fromJSON('[ [ 2251, "^The^ Winners^", "^T^1", 2, 0, 0, 0, [ 102, 153, 204 ], "WRITE SOMENTHING YOU ABOUT\n\n" ] ]')
Command results: nil [string]
|Tags||No tags attached.|
This actually gets even funnier - it is not just a random (new) table, it is a pointer to the same table which it resides in.
I'm going to look into it.
Okay, after some digging I've found out that ^T^, ^E^ and ^R^ are special internal sequences used for serialization of elements, tables and resources.
If you run: srun tb = fromJSON('[ [, "^T^1" ] ]')
Make sure that strings in your JSON don't start with those sequences, or else you may run into further issues.
Currently I don't have enough knowledge to come up with any reasonable solution, but this behaviour is undocumented and potentially dangerous.
Is there really no way to solve this problem? FromJSON is used by many servers to store data (including user generated content). This bug can potentially be utilized to break people's resources on purpose. In our case an entire core resource was malfunctioning. We can block these internal sequences ourselves but the thousands of other servers will not be aware of this issue/risk.