Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Unified Diff: remoting/webapp/client_screen.js

Issue 10221021: Protect all uses of JSON.parse against exceptions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reviewer comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/client_plugin_async.js ('k') | remoting/webapp/host_controller.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/client_screen.js
diff --git a/remoting/webapp/client_screen.js b/remoting/webapp/client_screen.js
index 9855c36f984f40c22870d4319e234d5270fad210..d6d8c2a974be0b23b6b20c264efa382d4f53f84e 100644
--- a/remoting/webapp/client_screen.js
+++ b/remoting/webapp/client_screen.js
@@ -375,14 +375,16 @@ function parseServerResponse_(xhr) {
console.log('parseServerResponse: xhr = ' + xhr);
if (xhr.status == 200) {
var host = /** @type {{data: {jabberId: string, publicKey: string}}} */
- JSON.parse(xhr.responseText);
- if (host.data && host.data.jabberId && host.data.publicKey) {
+ jsonParseSafe(xhr.responseText);
+ if (host && host.data && host.data.jabberId && host.data.publicKey) {
remoting.hostJid = host.data.jabberId;
remoting.hostPublicKey = host.data.publicKey;
var split = remoting.hostJid.split('/');
document.getElementById('connected-to').innerText = split[0];
startSession_();
return;
+ } else {
+ console.error('Invalid "support-hosts" response from server.');
}
}
var errorMsg = remoting.Error.GENERIC;
« no previous file with comments | « remoting/webapp/client_plugin_async.js ('k') | remoting/webapp/host_controller.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698