Skip to content
Snippets Groups Projects
Commit 4571295b authored by svornost's avatar svornost
Browse files

Strip unusable attributes from SVG elements when building the art cache.

parent 38678302
No related branches found
No related tags found
No related merge requests found
App.Art.cacheArtData = function() {
/** @param {Element} node */
function removeBadNamespaces(node) {
const attrs = node.attributes;
for (let index = 0; index < attrs.length; ++index) {
const attr = attrs[index];
if (attr.name.startsWith("sodipodi") || attr.name.startsWith("inkscape")) {
node.attributes.removeNamedItem(attr.name);
}
for (const child of node.children) {
removeBadNamespaces(child);
}
}
}
/**
* @param {NodeListOf<Element>} imagePassages
* @returns {Map<string, Element>}
......@@ -11,6 +25,7 @@ App.Art.cacheArtData = function() {
let div = document.createElement("div");
const svgData = atob(ip.innerHTML.replace(/data:image\/svg\+xml;base64,/, ''));
div.innerHTML = svgData.trim();
removeBadNamespaces(div.children.item(0));
dict.set(name, div.children.item(0));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment