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

Issue 10221021: Protect all uses of JSON.parse against exceptions. (Closed)

Created:
8 years, 8 months ago by Jamie
Modified:
8 years, 8 months ago
Reviewers:
Wez
CC:
chromium-reviews, jamiewalch+watch_chromium.org, dcaiafa+watch_chromium.org, simonmorris+watch_chromium.org, hclam+watch_chromium.org, wez+watch_chromium.org, amit, sanjeevr, garykac+watch_chromium.org, lambroslambrou+watch_chromium.org, alexeypa+watch_chromium.org, sergeyu+watch_chromium.org
Visibility:
Public.

Description

Protect all uses of JSON.parse against exceptions. BUG=None TEST=Manual Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=134407

Patch Set 1 #

Patch Set 2 : Log errors if JSON parsing fails. #

Total comments: 17

Patch Set 3 : Reviewer comments. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+67 lines, -42 lines) Patch
M remoting/webapp/client_plugin_async.js View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M remoting/webapp/client_screen.js View 1 1 chunk +4 lines, -2 lines 0 comments Download
M remoting/webapp/host_controller.js View 1 1 chunk +7 lines, -7 lines 0 comments Download
M remoting/webapp/host_list.js View 1 2 3 chunks +13 lines, -10 lines 0 comments Download
M remoting/webapp/oauth2.js View 1 2 chunks +21 lines, -17 lines 0 comments Download
M remoting/webapp/remoting.js View 1 2 chunks +19 lines, -3 lines 0 comments Download

Messages

Total messages: 6 (0 generated)
Jamie
ptal
8 years, 8 months ago (2012-04-27 20:30:29 UTC) #1
Sergey Ulanov
In most of these cases failure to parse JSON would indicate a bug in our ...
8 years, 8 months ago (2012-04-27 21:10:18 UTC) #2
Jamie
Good point. I've added console.error calls for all failures that didn't already have them.
8 years, 8 months ago (2012-04-27 21:36:46 UTC) #3
Wez
https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/client_plugin_async.js File remoting/webapp/client_plugin_async.js (right): https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/client_plugin_async.js#newcode90 remoting/webapp/client_plugin_async.js:90: remoting.ClientPluginAsync.prototype.handleMessage_ = function(message_str) { cleanup: message_str -> messageStr https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/host_list.js ...
8 years, 8 months ago (2012-04-28 00:00:42 UTC) #4
Jamie
https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/client_plugin_async.js File remoting/webapp/client_plugin_async.js (right): https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/client_plugin_async.js#newcode90 remoting/webapp/client_plugin_async.js:90: remoting.ClientPluginAsync.prototype.handleMessage_ = function(message_str) { On 2012/04/28 00:00:42, Wez wrote: ...
8 years, 8 months ago (2012-04-28 00:15:41 UTC) #5
Wez
8 years, 8 months ago (2012-04-28 00:32:03 UTC) #6
lgtm

https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/rem...
File remoting/webapp/remoting.js (right):

https://chromiumcodereview.appspot.com/10221021/diff/3001/remoting/webapp/rem...
remoting/webapp/remoting.js:288: function jsonParseSafe(jsonString) {
On 2012/04/28 00:15:41, Jamie wrote:
> On 2012/04/28 00:00:42, Wez wrote:
> > nit: parseJsonOrNull?
> 
> That was what I called it originally, but it doesn't return null (see below)
and
> jsonParseOrUndefined just didn't sound right.

In that case safeParseJson(), then? :)

Powered by Google App Engine
This is Rietveld 408576698