Bug 1947732 - Provide nsIPrincipal to GetTrustedTypesCompliantString. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D246424
This commit is contained in:
Tom Schuster
2025-04-30 11:09:07 +00:00
parent b1d9d0b790
commit edaa914b45
43 changed files with 177 additions and 114 deletions

View File

@@ -4327,7 +4327,7 @@ void Element::SetInnerHTML(const TrustedHTMLOrNullIsEmptyString& aInnerHTML,
const nsAString* compliantString =
TrustedTypeUtils::GetTrustedTypesCompliantString(
aInnerHTML, sink, kTrustedTypesOnlySinkGroup, *this,
compliantStringHolder, aError);
aSubjectPrincipal, compliantStringHolder, aError);
if (aError.Failed()) {
return;
@@ -4347,6 +4347,7 @@ void Element::GetOuterHTML(OwningTrustedHTMLOrNullIsEmptyString& aOuterHTML) {
}
void Element::SetOuterHTML(const TrustedHTMLOrNullIsEmptyString& aOuterHTML,
nsIPrincipal* aSubjectPrincipal,
ErrorResult& aError) {
constexpr nsLiteralString sink = u"Element outerHTML"_ns;
@@ -4354,7 +4355,7 @@ void Element::SetOuterHTML(const TrustedHTMLOrNullIsEmptyString& aOuterHTML,
const nsAString* compliantString =
TrustedTypeUtils::GetTrustedTypesCompliantString(
aOuterHTML, sink, kTrustedTypesOnlySinkGroup, *this,
compliantStringHolder, aError);
aSubjectPrincipal, compliantStringHolder, aError);
if (aError.Failed()) {
return;
}
@@ -4416,14 +4417,14 @@ enum nsAdjacentPosition { eBeforeBegin, eAfterBegin, eBeforeEnd, eAfterEnd };
void Element::InsertAdjacentHTML(
const nsAString& aPosition, const TrustedHTMLOrString& aTrustedHTMLOrString,
ErrorResult& aError) {
nsIPrincipal* aSubjectPrincipal, ErrorResult& aError) {
constexpr nsLiteralString kSink = u"Element insertAdjacentHTML"_ns;
Maybe<nsAutoString> compliantStringHolder;
const nsAString* compliantString =
TrustedTypeUtils::GetTrustedTypesCompliantString(
aTrustedHTMLOrString, kSink, kTrustedTypesOnlySinkGroup, *this,
compliantStringHolder, aError);
aSubjectPrincipal, compliantStringHolder, aError);
if (aError.Failed()) {
return;
@@ -5485,9 +5486,10 @@ EditorBase* Element::GetExtantEditor() const {
}
void Element::SetHTMLUnsafe(const TrustedHTMLOrString& aHTML,
nsIPrincipal* aSubjectPrincipal,
ErrorResult& aError) {
nsContentUtils::SetHTMLUnsafe(this, this, aHTML, false /*aIsShadowRoot*/,
aError);
aSubjectPrincipal, aError);
}
// https://html.spec.whatwg.org/#event-beforematch