Issue #2736 - Part 12: Re-work style <link> href attribute.

Use subject principal as triggering principal in style <link> "href"
attribute.
This commit is contained in:
Moonchild 2025-05-04 21:58:17 +02:00 committed by roytam1
commit 60ad5b2ffd
14 changed files with 51 additions and 29 deletions

View file

@ -374,6 +374,12 @@ HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
}
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::href) {
mTriggeringPrincipal = nsContentUtils::GetAttrTriggeringPrincipal(
this, aValue ? aValue->GetStringValue() : EmptyString(),
aSubjectPrincipal);
}
if (aValue) {
if (aNameSpaceID == kNameSpaceID_None &&
(aName == nsGkAtoms::href ||
@ -520,14 +526,20 @@ HTMLLinkElement::GetHrefURI() const
}
already_AddRefed<nsIURI>
HTMLLinkElement::GetStyleSheetURL(bool* aIsInline)
HTMLLinkElement::GetStyleSheetURL(bool* aIsInline, nsIPrincipal** aTriggeringPrincipal)
{
*aIsInline = false;
*aTriggeringPrincipal = nullptr;
nsAutoString href;
GetAttr(kNameSpaceID_None, nsGkAtoms::href, href);
if (href.IsEmpty()) {
return nullptr;
}
nsCOMPtr<nsIPrincipal> prin = mTriggeringPrincipal;
prin.forget(aTriggeringPrincipal);
nsCOMPtr<nsIURI> uri = Link::GetURI();
return uri.forget();
}