« get me outta code hell

html, language: html.escape() - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/language.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-10-20 13:02:53 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-10-20 13:07:03 -0300
commit4f69806230d69f215a873479f1728cc2fe5ebb46 (patch)
treeffa715fd3f3c925a4b0916c81ff2ee74903adea0 /src/data/things/language.js
parentf88043e17125affb9bb8e37d5b58e5a65e9c89d7 (diff)
html, language: html.escape()
Diffstat (limited to 'src/data/things/language.js')
-rw-r--r--src/data/things/language.js16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/data/things/language.js b/src/data/things/language.js
index 7750a1b3..46cff26a 100644
--- a/src/data/things/language.js
+++ b/src/data/things/language.js
@@ -171,7 +171,7 @@ export class Language extends Thing {
           if (!(strings || inheritedStrings)) return null;
           const allStrings = {...inheritedStrings, ...strings};
           return Object.fromEntries(
-            Object.entries(allStrings).map(([k, v]) => [k, this.escapeHTML(v)])
+            Object.entries(allStrings).map(([k, v]) => [k, html.escape(v)])
           );
         },
       },
@@ -202,18 +202,6 @@ export class Language extends Thing {
     }
   }
 
-  escapeHTML(string) {
-    // https://html.spec.whatwg.org/multipage/parsing.html#escapingString
-
-    string = string
-      .replaceAll('&', '&amp;')
-      .replaceAll('\u00a0', '&nbsp;')
-      .replaceAll('<', '&lt;')
-      .replaceAll('>', '&gt;');
-
-    return string;
-  }
-
   getUnitForm(value) {
     this.assertIntlAvailable('intl_pluralCardinal');
     return this.intl_pluralCardinal.select(value);
@@ -438,7 +426,7 @@ export class Language extends Thing {
   #sanitizeValueForInsertion(value) {
     switch (typeof value) {
       case 'string':
-        return this.escapeHTML(value);
+        return html.escape(value);
 
       case 'number':
       case 'boolean':