Project:
RSS

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009549New issuesMulti Theft Auto : San Andreaspublic2017-02-16 13:372017-02-20 23:53
ReporterSHC//Sniper 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Summary0009549: Erroneous fromJSON parsing
DescriptionCheck 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 Reproducesrun tb = fromJSON('[ [ 2251, "^The^ Winners^", "^T^0", 2, 0, 0, 0, [ 102, 153, 204 ], "WRITE SOMENTHING YOU ABOUT\n\n" ] ]')

srun tb[3]

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" ] ]')

srun tostring(tb[3])

Command results: nil [string]
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0025675)
pkpawelo (viewer)
2017-02-18 20:13
edited on: 2017-02-18 20:21

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.

srun tb
Command results: table: 1B474090 [table]

srun tb[3]
Command results: table: 1B474090 [table]

srun tb[3][3][3][3][3][3][3][3][3][3][3]
Command results: table: 1B474090 [table]

I'm going to look into it.

(0025677)
pkpawelo (viewer)
2017-02-20 23:44
edited on: 2017-02-20 23:53

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('[ [[123], "^T^1" ] ]')
then tb[2] will be pointer to [123] table and so on.

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.


- Issue History
Date Modified Username Field Change
2017-02-16 13:37 SHC//Sniper New Issue
2017-02-18 20:13 pkpawelo Note Added: 0025675
2017-02-18 20:21 pkpawelo Note Edited: 0025675 View Revisions
2017-02-20 23:44 pkpawelo Note Added: 0025677
2017-02-20 23:48 pkpawelo Note Edited: 0025677 View Revisions
2017-02-20 23:53 pkpawelo Note Edited: 0025677 View Revisions


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker