Bug 1301245 - Part 1. Download an SVG document only if the source URL consists of a reference(#) draft
authorcku <cku@mozilla.com>
Wed, 19 Jul 2017 19:45:34 +0800
changeset 612860 abd86c349ea16e6daf781d871caa7ad93a4de3e5
parent 612696 7d2e89fb92331d7e4296391213c1e63db628e046
child 612861 0fb921b21806c8f3aea9597d401eff4be14bee0c
push id69621
push userbmo:cku@mozilla.com
push dateFri, 21 Jul 2017 04:42:07 +0000
bugs1301245
milestone56.0a1
Bug 1301245 - Part 1. Download an SVG document only if the source URL consists of a reference(#) MozReview-Commit-ID: OT6ipv3qSj
layout/svg/nsSVGEffects.cpp
--- a/layout/svg/nsSVGEffects.cpp
+++ b/layout/svg/nsSVGEffects.cpp
@@ -392,19 +392,29 @@ nsSVGMarkerProperty::DoUpdate()
 NS_IMPL_ISUPPORTS(nsSVGMaskProperty, nsISupports)
 
 nsSVGMaskProperty::nsSVGMaskProperty(nsIFrame* aFrame)
 {
   const nsStyleSVGReset *svgReset = aFrame->StyleSVGReset();
 
   for (uint32_t i = 0; i < svgReset->mMask.mImageCount; i++) {
     nsCOMPtr<nsIURI> maskUri = nsSVGEffects::GetMaskURI(aFrame, i);
-    nsSVGPaintingProperty* prop = new nsSVGPaintingProperty(maskUri, aFrame,
-                                                            false);
-    mProperties.AppendElement(prop);
+    bool hasRef = false;
+    if (maskUri) {
+      maskUri->GetHasRef(&hasRef);
+    }
+
+    // An URL refering to an SVG mask resource must have a reference(#).
+    if (!hasRef) {
+      mProperties.AppendElement(nullptr);
+    } else {
+      nsSVGPaintingProperty* prop = new nsSVGPaintingProperty(maskUri, aFrame,
+                                                              false);
+      mProperties.AppendElement(prop);
+    }
   }
 }
 
 bool
 nsSVGTextPathProperty::TargetIsValid()
 {
   Element* target = GetTarget();
   return target && target->IsSVGElement(nsGkAtoms::path);
@@ -651,20 +661,24 @@ nsSVGEffects::EffectProperties::GetMaskF
 {
   nsTArray<nsSVGMaskFrame *> result;
   if (!mMask)
     return result;
 
   bool ok = true;
   const nsTArray<RefPtr<nsSVGPaintingProperty>>& props = mMask->GetProps();
   for (size_t i = 0; i < props.Length(); i++) {
-    nsSVGMaskFrame* maskFrame = static_cast<nsSVGMaskFrame*>(
-      props[i]->GetReferencedFrame(LayoutFrameType::SVGMask, &ok));
-    MOZ_ASSERT(!maskFrame || ok);
-    result.AppendElement(maskFrame);
+    if (props[i]) {
+      nsSVGMaskFrame* maskFrame = static_cast<nsSVGMaskFrame*>(
+        props[i]->GetReferencedFrame(LayoutFrameType::SVGMask, &ok));
+      MOZ_ASSERT(!maskFrame || ok);
+      result.AppendElement(maskFrame);
+    } else {
+      result.AppendElement(nullptr);
+    }
   }
 
   return result;
 }
 
 bool
 nsSVGEffects::EffectProperties::HasNoOrValidEffects()
 {
@@ -688,19 +702,21 @@ nsSVGEffects::EffectProperties::HasNoOrV
 
 bool
 nsSVGEffects::EffectProperties::HasNoOrValidMask()
 {
   if (mMask) {
     bool ok = true;
     const nsTArray<RefPtr<nsSVGPaintingProperty>>& props = mMask->GetProps();
     for (size_t i = 0; i < props.Length(); i++) {
-      props[i]->GetReferencedFrame(LayoutFrameType::SVGMask, &ok);
-      if (!ok) {
-        return false;
+      if (props[i]) {
+        props[i]->GetReferencedFrame(LayoutFrameType::SVGMask, &ok);
+        if (!ok) {
+          return false;
+        }
       }
     }
   }
 
   return true;
 }
 
 void