Bug 1308121-Handle unrecognized content type parameter when trying to get supported capability.
MozReview-Commit-ID: GqSjn6BjhTi
--- a/dom/media/eme/MediaKeySystemAccess.cpp
+++ b/dom/media/eme/MediaKeySystemAccess.cpp
@@ -636,16 +636,47 @@ AllCodecsOfType(const nsTArray<GMPCodecS
for (const GMPCodecString& codec : aCodecs) {
if (GetCodecType(codec) != aCodecType) {
return false;
}
}
return true;
}
+static bool
+IsParameterUnrecognized(const nsAString& aContentType)
+{
+ nsAutoString contentType(aContentType);
+ contentType.StripWhitespace();
+
+ nsTArray<nsString> params;
+ nsAString::const_iterator start, end, semicolon, equalSign;
+ contentType.BeginReading(start);
+ contentType.EndReading(end);
+ semicolon = start;
+ // Find any substring between ';' & '='.
+ while (semicolon != end) {
+ if (FindCharInReadable(';', semicolon, end)) {
+ equalSign = ++semicolon;
+ if (FindCharInReadable('=', equalSign, end)) {
+ params.AppendElement(Substring(semicolon, equalSign));
+ semicolon = equalSign;
+ }
+ }
+ }
+
+ for (auto param : params) {
+ if (!param.LowerCaseEqualsLiteral("codecs") &&
+ !param.LowerCaseEqualsLiteral("profiles")) {
+ return true;
+ }
+ }
+ return false;
+}
+
// 3.1.2.3 Get Supported Capabilities for Audio/Video Type
static Sequence<MediaKeySystemMediaCapability>
GetSupportedCapabilities(const CodecType aCodecType,
mozIGeckoMediaPluginService* aGMPService,
const nsTArray<MediaKeySystemMediaCapability>& aRequestedCapabilities,
const MediaKeySystemConfiguration& aPartialConfig,
const KeySystemConfig& aKeySystem,
DecoderDoctorDiagnostics* aDiagnostics)
@@ -744,16 +775,20 @@ GetSupportedCapabilities(const CodecType
NS_ConvertUTF16toUTF8(robustness).get());
continue;
}
// Let parameters be the RFC 6381[RFC6381] parameters, if any, specified by
// content type.
// If the user agent does not recognize one or more parameters, continue to
// the next iteration.
+ if (IsParameterUnrecognized(contentType)) {
+ continue;
+ }
+
// Let media types be the set of codecs and codec constraints specified by
// parameters. The case-sensitivity of string comparisons is determined by
// the appropriate RFC or other specification.
// (Note: codecs array is 'parameter').
// If media types is empty:
if (codecs.IsEmpty()) {
// If container normatively implies a specific set of codecs and codec constraints: