From 63121b1045ca6b719299e6025199af7e9619323d Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 8 May 2017 10:21:35 -0700 Subject: [PATCH] Don't recurse on serverCertificate in config merge 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 --- lib/util/config_utils.js | 4 +++- test/player_unit.js | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/lib/util/config_utils.js b/lib/util/config_utils.js index acd89f1955..fe5a292784 100644 --- a/lib/util/config_utils.js +++ b/lib/util/config_utils.js @@ -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)) { diff --git a/test/player_unit.js b/test/player_unit.js index 9c1698032b..3351931c40 100644 --- a/test/player_unit.js +++ b/test/player_unit.js @@ -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() {