Bug 1804339 - Fix relative url conversion for SVG image and script when saving pages r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D164216
This commit is contained in:
Robert Longson 2022-12-13 07:35:01 +00:00
parent 61e4227eed
commit 7990272a30
4 changed files with 15 additions and 2 deletions

View File

@ -458,7 +458,9 @@ nsresult ResourceReader::OnWalkDOMNode(nsINode* aNode) {
return NS_OK;
}
if (aNode->IsSVGElement(nsGkAtoms::img)) {
if (aNode->IsSVGElement(nsGkAtoms::image)) {
MOZ_TRY(OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_IMAGE,
"href"));
return OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_IMAGE,
"href", "http://www.w3.org/1999/xlink");
}
@ -500,6 +502,8 @@ nsresult ResourceReader::OnWalkDOMNode(nsINode* aNode) {
}
if (aNode->IsSVGElement(nsGkAtoms::script)) {
MOZ_TRY(OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_SCRIPT,
"href"));
return OnWalkAttribute(aNode->AsElement(), nsIContentPolicy::TYPE_SCRIPT,
"href", "http://www.w3.org/1999/xlink");
}
@ -993,7 +997,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids,
return rv;
}
if (content->IsSVGElement(nsGkAtoms::img)) {
if (content->IsSVGElement(nsGkAtoms::image)) {
nsresult rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut) {
// Disable image loads
@ -1001,6 +1005,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids,
if (imgCon) imgCon->SetLoadingEnabled(false);
// FixupAnchor(*aNodeOut); // XXXjwatt: is this line needed?
FixupAttribute(*aNodeOut, "href");
FixupAttribute(*aNodeOut, "href", "http://www.w3.org/1999/xlink");
}
return rv;
@ -1017,6 +1022,7 @@ PersistNodeFixup::FixupNode(nsINode* aNodeIn, bool* aSerializeCloneKids,
if (content->IsSVGElement(nsGkAtoms::script)) {
nsresult rv = GetNodeToFixup(aNodeIn, aNodeOut);
if (NS_SUCCEEDED(rv) && *aNodeOut) {
FixupAttribute(*aNodeOut, "href");
FixupAttribute(*aNodeOut, "href", "http://www.w3.org/1999/xlink");
}
return rv;

View File

@ -8,5 +8,6 @@ support-files =
[browser_persist.js]
support-files =
file_persist_srcset.html
file_persist_svg.html
file_persist_picture_source.html
file_persist_image.png

View File

@ -14,6 +14,7 @@ const chromeBase =
const REFTESTS = [
"file_persist_srcset.html",
"file_persist_picture_source.html",
"file_persist_svg.html",
// ...
];

View File

@ -0,0 +1,5 @@
<!doctype html>
<svg>
<image href="file_persist_image.png"/>
<image x="100" xlink:href="file_persist_image.png"/>
</svg>