awiebe / burningthumb-vk-manage

This is only an issue tracker, please do ot push code to this repo.
0 stars 0 forks source link

Folder content array incorrectly encoded #24

Closed awiebe closed 7 years ago

awiebe commented 7 years ago

[/LJ17 DITP 000054.mp4] is not a valid JSON array, each string item must be quoted,special characters must also be escaped (use a proper serializer device side).

burningthumb commented 7 years ago

The management interface needs to handle the reports in the current format. In other words you need to parse it as it is which is [ comma separated list of filenames ]. In protocol version 2 it can be changed to a JSON Array.

burningthumb commented 7 years ago

As an FYI, if you are wondering where this format came from I did not make it up, its what you get if you invoke the toString method on an array in Android (which is what is being done).

awiebe commented 7 years ago

All Java objects have the builtin method toString() which you can override to print whatever format you want, they aren't required to be encoded in any particular way. The most reasonable place to catch the protocol differences is when we get a report. Please modify put.json to parse according to protocol version, but always store a json array.

Note: Any folder content containing , in the name will be parsed incorrectly, and there is no way to distinguish it from an array separator, so if nothing else you may want to modify the legacy protocol with the following

for(String s in myFolderContentArrayList)
  myNewFolderContentArrayList.add(s.replace("'","\'");
out = myNewFolderContentArrayList.toString()

On the server side for now parsing legacy array, this should create an acceptable serialization

$nobrackets = substr(in,1,strlen($_POST['foldercontent'])-2)
$a=explode(',',$nobrackets);
$json=json_encode($a)
//storage logic
burningthumb commented 7 years ago

The put.php script has been modified to convert all "legacy" arrays to JSON arrays prior to storage in the database. Fields affected are: "onetouchplay" "filesize" "foldercontent" "emptyfiles" "areabwidgets" "areacwidgets" "areadwidgets". The conversion code is:

$nobrackets = substr($a_legacyArray,1,strlen($in)-1); $a = explode(',',$nobrackets); $json = json_encode($a, true);