From 4571295bb098e17c49ee76c01589d5a56b872558 Mon Sep 17 00:00:00 2001
From: Svornost <11434-svornost@users.noreply.gitgud.io>
Date: Thu, 4 Jun 2020 15:44:33 -0700
Subject: [PATCH] Strip unusable attributes from SVG elements when building the
 art cache.

---
 js/artInfrastructure.js | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/js/artInfrastructure.js b/js/artInfrastructure.js
index 6b3bf218b0e..b416cc6d469 100644
--- a/js/artInfrastructure.js
+++ b/js/artInfrastructure.js
@@ -1,4 +1,18 @@
 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));
 		}
 
-- 
GitLab