Bug 1410281 - Use GetBaseURIForStyleAttr for style attribute base URI in nsTreeSanitizer. r=xidorn draft
authorCameron McCormack <cam@mcc.id.au>
Fri, 20 Oct 2017 09:58:57 +0800
changeset 683675 da7c116d3443d41e58eb90acdce0560a41a38f9c
parent 683653 b6ba3e919f561bfabbf4bec7f0f53a23c360adee
child 736698 f03ef962f2cef9280f1e101e412994ca951fa135
push id85431
push userbmo:cam@mcc.id.au
push dateFri, 20 Oct 2017 01:59:10 +0000
reviewersxidorn
bugs1410281
milestone58.0a1
Bug 1410281 - Use GetBaseURIForStyleAttr for style attribute base URI in nsTreeSanitizer. r=xidorn MozReview-Commit-ID: IBc7zEHTDAQ
dom/base/nsTreeSanitizer.cpp
--- a/dom/base/nsTreeSanitizer.cpp
+++ b/dom/base/nsTreeSanitizer.cpp
@@ -1155,26 +1155,26 @@ nsTreeSanitizer::SanitizeAttributes(mozi
 
   for (int32_t i = ac - 1; i >= 0; --i) {
     const nsAttrName* attrName = aElement->GetAttrNameAt(i);
     int32_t attrNs = attrName->NamespaceID();
     RefPtr<nsAtom> attrLocal = attrName->LocalName();
 
     if (kNameSpaceID_None == attrNs) {
       if (aAllowStyle && nsGkAtoms::style == attrLocal) {
-        nsCOMPtr<nsIURI> baseURI = aElement->GetBaseURI();
         nsIDocument* document = aElement->OwnerDoc();
         // Pass the CSS Loader object to the parser, to allow parser error
         // reports to include the outer window ID.
         nsCSSParser parser(document->CSSLoader());
         nsAutoString value;
         aElement->GetAttr(attrNs, attrLocal, value);
         RefPtr<mozilla::css::Declaration> decl =
           parser.ParseStyleAttribute(value, document->GetDocumentURI(),
-                                     baseURI, document->NodePrincipal());
+                                     aElement->GetBaseURIForStyleAttr(),
+                                     document->NodePrincipal());
         if (decl) {
           nsAutoString cleanValue;
           if (SanitizeStyleDeclaration(decl, cleanValue)) {
             aElement->SetAttr(kNameSpaceID_None,
                               nsGkAtoms::style,
                               cleanValue,
                               false);
           }