Skip to content

Commit

Permalink
Don't recurse on serverCertificate in config merge
Browse files Browse the repository at this point in the history
Treating serverCertificate as an Object and recursing causes an
exception the second time you set the serverCertificate config.

As a quick fix that can be cherry-picked for v2.1.x, do not recurse
on serverCertificate.  This has the side-effect of not type-checking
the serverCertificate field on input.

A more detailed fix will be made later, for inclusion in v2.2.

Issue #784

Change-Id: I84c05ee3dd370a4b83e9ce2337d2326ec36532c2
  • Loading branch information
joeyparrish committed May 8, 2017
1 parent 67fa39c commit 63121b1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/util/config_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ shaka.util.ConfigUtils.mergeConfigObjects =
*/
var copyObject = !!({
'.abr.manager': true
})[subPath];
})[subPath] || !!({
'serverCertificate': true
})[k];

// The order of these checks is important.
if (!ignoreKeys && !(k in destination)) {
Expand Down
23 changes: 23 additions & 0 deletions test/player_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,29 @@ describe('Player', function() {
expect(newConfig.manifest.dash.customScheme).not.toBe(badCustomScheme2);
expect(logWarnSpy).not.toHaveBeenCalled();
});

// Regression test for https://github.com/google/shaka-player/issues/784
it('does not throw when overwriting serverCertificate', function() {
player.configure({
drm: {
advanced: {
'com.widevine.alpha': {
serverCertificate: new Uint8Array(1)
}
}
}
});

player.configure({
drm: {
advanced: {
'com.widevine.alpha': {
serverCertificate: new Uint8Array(2)
}
}
}
});
});
});

describe('AbrManager', function() {
Expand Down

0 comments on commit 63121b1

Please sign in to comment.