I have a hosted PHP application which echoes a large JSON string and Mozilla suddenly started to show the below error in dev tools:
SyntaxError: JSON.parse: bad Unicode escape at line 1 column 1048577 of the JSON data
(Tried chrome & Mozilla, it fails in both, only Chrome doesn't show any errors)
If the response size is reduced, then the problem disappears.
At the front the code is something like this (removed some stuff for clarity)
function DataManager() {
$http.get("datamanager.php")
.success(function (data) {
$scope.fulldata = data.fulldata;
$scope.datagroups = data.datagroups;
//More code.......
})
.error(function (data, status, headers, config) {
//Code removed.....
});
}
At the back, there is a PHP script running which makes an "echo" and returns the JSON data.
$fulldata = json_encode($treedata);
$datagroups = json_encode($datagroups);
header('Content-Type: application/json');
echo '{ "fulldata" : ' . $fulldata . ","
. ' "datagroups" : ' . $datagroups
. "}";
die;
Added error_log checks, saved the JSON result to a file using file_put_contents and it's perfectly fine. Uploaded it to online JSON check tools and got no errors.
Tried to find any PHP/Apache restrictions about response size but no luck. Checked the DB/JSON data for possible strange characters or anything that might look suspicious but couldn't find anything.
My host uses fail2ban & mod_security , could they affect the PHP response size?
Pagination style (Page1.....Page X) is out of the question, the full data is needed. We started already to make changes in order to send data in chunks of less than 1M.
Any ideas are welcome.