From 81c0eaf03f23cf3f259b8c7e18daa01209e59589 Mon Sep 17 00:00:00 2001
From: Tim Hostetler <6970899+thostetler@users.noreply.github.com>
Date: Mon, 12 Jan 2026 00:39:24 -0500
Subject: [PATCH] SCIX-684 fix: strip HTML tags from document title on abstract
pages
Article titles containing HTML/MathML markup (for scientific notation
like Greek letters, subscripts, superscripts) were being rendered
directly in document.title, showing raw markup instead of plain text.
- Strip HTML tags in _updateDocumentTitle() using jQuery text extraction
- Add unit test verifying MathML and HTML tags are properly stripped
---
src/js/components/navigator.js | 8 +++--
.../mocha/js/apps/discovery/navigator.spec.js | 32 +++++++++++++++++++
2 files changed, 38 insertions(+), 2 deletions(-)
diff --git a/src/js/components/navigator.js b/src/js/components/navigator.js
index 4db6edbe5..cda9098e5 100644
--- a/src/js/components/navigator.js
+++ b/src/js/components/navigator.js
@@ -278,6 +278,10 @@ define([
_updateDocumentTitle: function (title) {
if (_.isUndefined(title) || title === false) return;
+
+ // Strip HTML tags from title for document.title
+ var plainTitle = $('
').html(title).text();
+
var currTitle = this.storage.getDocumentTitle();
var setDocTitle = _.bind(function (t) {
document.title = t === '' ? APP_TITLE : t + TITLE_SEP + APP_TITLE;
@@ -285,8 +289,8 @@ define([
}, this);
// title is defined and it is different from the current one, it should be updated
- if (title !== currTitle) {
- setDocTitle(title);
+ if (plainTitle !== currTitle) {
+ setDocTitle(plainTitle);
}
},
diff --git a/test/mocha/js/apps/discovery/navigator.spec.js b/test/mocha/js/apps/discovery/navigator.spec.js
index 3fdc68ddd..44041fea8 100644
--- a/test/mocha/js/apps/discovery/navigator.spec.js
+++ b/test/mocha/js/apps/discovery/navigator.spec.js
@@ -373,7 +373,39 @@ define([
done();
})
+ it("should strip HTML tags from document title", function() {
+ var n = new Navigator();
+
+ var storedTitle = null;
+ var storage = {
+ getDocumentTitle: function() {
+ return storedTitle;
+ },
+ setDocumentTitle: function(t) {
+ storedTitle = t;
+ }
+ };
+ n.storage = storage;
+
+ // Test with MathML markup (like scientific article titles)
+ var htmlTitle = 'Observation of Λ Hyperon';
+ n._updateDocumentTitle(htmlTitle);
+
+ // The stored title should have HTML stripped
+ expect(storedTitle).to.eql('Observation of Λ Hyperon');
+ expect(document.title).to.contain('Observation of Λ Hyperon');
+
+ // Test with simple HTML tags
+ storedTitle = null;
+ n._updateDocumentTitle('A fancy title with superscript');
+ expect(storedTitle).to.eql('A fancy title with superscript');
+
+ // Test with plain text (no change expected)
+ storedTitle = null;
+ n._updateDocumentTitle('Plain text title');
+ expect(storedTitle).to.eql('Plain text title');
+ });
});