Bug 1301245 - Part 1. Download an SVG document only if the source URL consists of a reference(#)
MozReview-Commit-ID: OT6ipv3qSj
--- 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