app: decode XML entities in the story title
- ID
16efa14- date
2026-08-10 03:36:26+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
0bc2fdf- message
app: decode XML entities in the story title- changed files
4 files, 30 additions, 2 deletions
Changed files
CHANGELOG.md (52 → 118)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0af522c..5f7b6b4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+## v1.0.1 - 2026-08-10
+
+Fix a bug with ampersands in fic titles.
+
## v1.0 - 2025-01-26
Initial version.
index.html (13604 → 13606)
diff --git a/index.html b/index.html
index eb8f4d0..6e8b8c4 100644
--- a/index.html
+++ b/index.html
@@ -145,7 +145,7 @@
<main>
<h1>
Add cover images to EPUBs from AO3
- <span class="version">v1.0</span>
+ <span class="version">v1.0.1</span>
</h1>
<noscript>
static/app.js (15019 → 15300)
diff --git a/static/app.js b/static/app.js
index 6f835fa..cbda495 100644
--- a/static/app.js
+++ b/static/app.js
@@ -154,11 +154,22 @@ async function getKeyFicInfo(zip) {
console.debug(`Detected fandom in first HTML file: ${fandom}`);
- return { title, author, fandom };
+ return { title: decodeXML(title), author, fandom };
}
+/**
+ * Decode the XML entities in a string.
+ */
+function decodeXML(input) {
+ if (/&|"|'|'<|>/.test(input)) {
+ var doc = new DOMParser().parseFromString(input, "text/html");
+ return doc.documentElement.textContent;
+ }
+ return input;
+}
+
/**
test/app.js (2597 → 2996)
diff --git a/test/app.js b/test/app.js
index a5ac31a..ecffae2 100644
--- a/test/app.js
+++ b/test/app.js
@@ -42,6 +42,19 @@ QUnit.module('getKeyFicInfo', () => {
}
);
});
+
+ // Downloaded from https://archiveofourown.org/works/32257177, 10 August 2026
+ QUnit.test('it escapes ampersands in the title', (assert) => {
+ assertGetsTheRightKeyInfo(
+ assert,
+ 'test/fixtures/Loki_Sylvie_Two.epub',
+ {
+ title: 'Loki & Sylvie: Two Awesomely Genderfluid Variants',
+ author: 'KetchupOnToast',
+ fandom: 'Loki (TV 2021)'
+ }
+ );
+ });
});