Skip to content

Commit

Permalink
Fix PlayReady challenge format (#3120)
Browse files Browse the repository at this point in the history
* KeySystemPlayReady: set utf-8 format by default for challenge request (if not set in PlayReadyKeyMessage)

* update unit test
  • Loading branch information
bbert authored and jeoliva committed Nov 27, 2019
1 parent a7a6279 commit d5e0577
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/streaming/protection/drm/KeySystemPlayReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ function KeySystemPlayReady(config) {
for (let i = 0; i < headerNameList.length; i++) {
headers[headerNameList[i].childNodes[0].nodeValue] = headerValueList[i].childNodes[0].nodeValue;
}
// some versions of the PlayReady CDM return 'Content' instead of 'Content-Type'.
// Some versions of the PlayReady CDM return 'Content' instead of 'Content-Type'.
// this is NOT w3c conform and license servers may reject the request!
// -> rename it to proper w3c definition!
if (headers.hasOwnProperty('Content')) {
headers['Content-Type'] = headers.Content;
delete headers.Content;
}
// some devices (Ex: LG SmartTVs) require content-type to be defined
// Set Content-Type header by default if not provided in the the CDM message (<PlayReadyKeyMessage/>)
// or if the message contains directly the challenge itself (Ex: LG SmartTVs)
if (!headers.hasOwnProperty('Content-Type')) {
headers['Content-Type'] = 'text/xml; charset=' + messageFormat;
headers['Content-Type'] = 'text/xml; charset=utf-8';
}
return headers;
}
Expand All @@ -101,6 +102,9 @@ function KeySystemPlayReady(config) {
licenseRequest = BASE64.decode(Challenge);
}
} else {
// The message from CDM is not a wrapped message as on IE11 and Edge,
// thus it contains direclty the challenge itself
// (note that the xmlDoc at this point may be unreadable since it may have been interpreted as UTF-16)
return message;
}

Expand Down Expand Up @@ -309,4 +313,4 @@ function KeySystemPlayReady(config) {
}

KeySystemPlayReady.__dashjs_factory_name = 'KeySystemPlayReady';
export default dashjs.FactoryMaker.getSingletonFactory(KeySystemPlayReady); /* jshint ignore:line */
export default dashjs.FactoryMaker.getSingletonFactory(KeySystemPlayReady); /* jshint ignore:line */
6 changes: 3 additions & 3 deletions test/unit/streaming.protection.drm.KeySystemPlayReady.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ describe('KeySystemPlayready', function () {
expect(licenseRequest).to.be.undefined; // jshint ignore:line
});

it('should return null when getRequestHeadersFromMessage is called without parameter', function () {
it('should return at least Content-Type header when getRequestHeadersFromMessage is called without parameter', function () {
const requestHeaders = keySystem.getRequestHeadersFromMessage();
expect(requestHeaders['Content-Type']).to.equal('text/xml; charset=utf-16');
expect(requestHeaders['Content-Type']).to.equal('text/xml; charset=utf-8');
});

it('should return the correct cdmData', function () {
Expand All @@ -111,4 +111,4 @@ describe('KeySystemPlayready', function () {
expect(cdmDataString).to.equal(expectedCDMData);
});
});
});
});

0 comments on commit d5e0577

Please sign in to comment.