Resolve XML entities in parsed strings (#4664)
Some checks are pending
CI / Build, Upload, Test (push) Waiting to run

This commit is contained in:
Abe Jellinek 2024-09-03 10:24:01 -04:00 committed by Dan Stillman
parent af3602124b
commit 5bd5bfa343

View file

@ -94,12 +94,19 @@ Zotero.Intl = new function () {
const intlFiles = ['zotero.dtd', 'preferences.dtd', 'mozilla/editMenuOverlay.dtd'];
let strings = [];
let { documentElement: elem } = new DOMParser().parseFromString('<root></root>', 'application/xml');
for (let intlFile of intlFiles) {
let localeXML = Zotero.File.getContentsFromURL(`chrome://zotero/locale/${intlFile}`);
let regexp = /<!ENTITY ([^\s]+)\s+"([^"]+)/g;
let regexpResult;
while ((regexpResult = regexp.exec(localeXML))) {
strings[regexpResult[1]] = regexpResult[2];
let key = regexpResult[1];
let value = regexpResult[2];
// Resolve XML entities
elem.innerHTML = value;
value = elem.textContent;
strings[key] = value;
}
}
return strings;