From b2560306020f6329ddaf0320dc010ea23af0f58c Mon Sep 17 00:00:00 2001 From: Azgaar Date: Sat, 27 Feb 2021 01:03:08 +0300 Subject: [PATCH] v1.5.73 - better: remove sodipodi and inkscape attributes on load --- index.html | 4 +--- modules/ui/emblems-editor.js | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 4a60cc17..4ae003e0 100644 --- a/index.html +++ b/index.html @@ -42,9 +42,7 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"> + xmlns:svg="http://www.w3.org/2000/svg"> diff --git a/modules/ui/emblems-editor.js b/modules/ui/emblems-editor.js index 679c33d3..83758d66 100644 --- a/modules/ui/emblems-editor.js +++ b/modules/ui/emblems-editor.js @@ -238,8 +238,26 @@ function editEmblem(type, id, el) { const svg = ``; defs.insertAdjacentHTML("beforeend", svg); } else { - defs.insertAdjacentHTML("beforeend", result); - const newEmblem = defs.lastChild; // new coa + + const el = document.createElement("html"); + el.innerHTML = result; + + // remove sodipodi and inkscape attributes + el.querySelectorAll("*").forEach(el => { + const attributes = el.getAttributeNames(); + attributes.forEach(attr => { + if (attr.includes("inkscape") || attr.includes("sodipodi")) el.removeAttribute(attr); + }); + }); + + const g = el.querySelector("g"); + + if (!g) { + tip("The file should be prepated for load to FMG. Please use Armoria or other relevant tools", false, "error"); + return; + } + + const newEmblem = defs.appendChild(g); newEmblem.id = id; newEmblem.setAttribute("width", 200); newEmblem.setAttribute("height", 200);