Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PlayReady challenge format #3120

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});
});
});