Skip to content

Commit

Permalink
Replace new Function() with JSON.parse()
Browse files Browse the repository at this point in the history
  • Loading branch information
josteink committed Dec 9, 2016
1 parent 0e4732c commit a83436f
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/gmail.js
Original file line number Diff line number Diff line change
Expand Up @@ -891,10 +891,8 @@ var Gmail_ = function(localJQuery) {
endIndex = (parseInt(dataLength, 10) - 2) + response.indexOf("[");
data = response.substring(response.indexOf("["), endIndex);

var get_data = new Function("\"use strict\"; return " + data);
realData = get_data();

parsedResponse.push(realData);
var json = JSON.parse(data);
parsedResponse.push(json);

// prepare response for next loop
response = response.substring(response.indexOf("["), response.length);
Expand Down Expand Up @@ -1684,11 +1682,9 @@ var Gmail_ = function(localJQuery) {
return emails;
}

get_data = get_data.substring(get_data.indexOf("["), get_data.length);
get_data = "\"use strict\"; return " + get_data;
get_data = new Function(get_data);

api.tracker.view_data = get_data();
var data = get_data.substring(get_data.indexOf("["), get_data.length);
var json = JSON.parse(data);
api.tracker.view_data = json;

for(var i in api.tracker.view_data) {
if (typeof(api.tracker.view_data[i]) === "function") {
Expand Down Expand Up @@ -1934,13 +1930,10 @@ var Gmail_ = function(localJQuery) {
if (!get_data) {
return {};
}
get_data = get_data.substring(get_data.indexOf("["), get_data.length);
get_data = "\"use strict\"; return " + get_data;
get_data = new Function(get_data);

var cdata = get_data();
var data = get_data.substring(get_data.indexOf("["), get_data.length);
var json = JSON.parse(data);

api.tracker.email_data = cdata[0];
api.tracker.email_data = json[0];
return api.tools.parse_email_data(api.tracker.email_data);
};

Expand Down

0 comments on commit a83436f

Please sign in to comment.