diff options
author | rmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 01:50:21 +0000 |
---|---|---|
committer | rmsousa@chromium.org <rmsousa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-03 01:50:21 +0000 |
commit | 493b10e859bdd76685ab7f233b5019025c600b4c (patch) | |
tree | d7a745fd3db13f09832ff42a17d0f5184c6af200 /remoting/webapp | |
parent | d1ca2166054258c881ebd087b294f7e55e514a58 (diff) | |
download | chromium_src-493b10e859bdd76685ab7f233b5019025c600b4c.zip chromium_src-493b10e859bdd76685ab7f233b5019025c600b4c.tar.gz chromium_src-493b10e859bdd76685ab7f233b5019025c600b4c.tar.bz2 |
Deal with empty lists being omitted from the server's JSON response.
There are two places where we use lists in our REST API - the return of the List API (/hosts), and the tokenUrlPatterns list for each host.
Both places that handle those fields currently assume that an empty list will be returned explicitly as a 0-length array ([]) when in practice the fields are simply undefined. This CL fixes both places to deal with an undefined field correctly.
BUG=267293
Review URL: https://chromiumcodereview.appspot.com/21703002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@215449 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/webapp')
-rw-r--r-- | remoting/webapp/host_list.js | 2 | ||||
-rw-r--r-- | remoting/webapp/third_party_token_fetcher.js | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/remoting/webapp/host_list.js b/remoting/webapp/host_list.js index 99ad354..afc276b1 100644 --- a/remoting/webapp/host_list.js +++ b/remoting/webapp/host_list.js @@ -181,6 +181,8 @@ remoting.HostList.prototype.parseHostListResponse_ = function(onDone, xhr) { return 0; }; this.hosts_ = /** @type {Array} */ this.hosts_.sort(cmp); + } else { + this.hosts_ = []; } } else { this.lastError_ = remoting.Error.UNEXPECTED; diff --git a/remoting/webapp/third_party_token_fetcher.js b/remoting/webapp/third_party_token_fetcher.js index a16246c..ffe9120 100644 --- a/remoting/webapp/third_party_token_fetcher.js +++ b/remoting/webapp/third_party_token_fetcher.js @@ -60,6 +60,12 @@ remoting.ThirdPartyTokenFetcher = function( * Fetch a token with the parameters configured in this object. */ remoting.ThirdPartyTokenFetcher.prototype.fetchToken = function() { + // If there is no list of patterns, this host cannot use a token URL. + if (!this.tokenUrlPatterns_) { + console.error('No token URLs are allowed for this host'); + this.failFetchToken_(); + } + // Verify the host-supplied URL matches the domain's allowed URL patterns. for (var i = 0; i < this.tokenUrlPatterns_.length; i++) { if (this.tokenUrl_.match(this.tokenUrlPatterns_[i])) { @@ -68,7 +74,6 @@ remoting.ThirdPartyTokenFetcher.prototype.fetchToken = function() { hostPermissions.getPermission( this.fetchTokenInternal_, this.failFetchToken_); - return; } } |