From a0da169664ecbf8fdb2d8242fbfd533a097ffc66 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 2 Oct 2024 00:37:27 -0400 Subject: [PATCH] Strip non-printable characters in tab titles when restoring session https://forums.zotero.org/discussion/118303/zotero-blocked-with-the-loading-items-message and probably others Fixes #4721 --- chrome/content/zotero/tabs.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/tabs.js b/chrome/content/zotero/tabs.js index b18e818b62..ba3467d8e1 100644 --- a/chrome/content/zotero/tabs.js +++ b/chrome/content/zotero/tabs.js @@ -206,9 +206,13 @@ var Zotero_Tabs = new function () { } else if (tab.type === 'reader') { if (Zotero.Items.exists(tab.data.itemID)) { + // Strip non-printable characters, which can result in DOM syntax errors + // ("An invalid or illegal string was specified") -- reproduced with "\u0001" + // in a title in session.json + let title = tab.title.replace(/[\u0000-\u001F\u007F-\u009F]/g, ""); this.add({ type: 'reader-unloaded', - title: tab.title, + title, index: i, data: tab.data, select: tab.selected