From c7d30ebde445c43dafc3aa963129ed75e53bbf89 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 20 Apr 2023 15:50:57 -0400 Subject: [PATCH] Allow disabling JavaScript in basic viewer (#3089) And: - Prevent JavaScript inside notes from executing in reports - Update calls to openInViewer() to pass an options object --- .../zotero/preferences/preferences_cite.jsx | 26 ++++++++-------- .../zotero/preferences/preferences_cite.xhtml | 4 +-- chrome/content/zotero/reportInterface.js | 4 +-- .../content/zotero/standalone/basicViewer.js | 19 +++++++++--- .../content/zotero/standalone/standalone.js | 30 ++++++++++--------- chrome/content/zotero/xpcom/zotero.js | 26 +++++++++++----- chrome/content/zotero/zoteroPane.xhtml | 2 +- 7 files changed, 69 insertions(+), 42 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_cite.jsx b/chrome/content/zotero/preferences/preferences_cite.jsx index 0eee275765..43aad931c6 100644 --- a/chrome/content/zotero/preferences/preferences_cite.jsx +++ b/chrome/content/zotero/preferences/preferences_cite.jsx @@ -140,18 +140,20 @@ Zotero_Preferences.Cite = { openStylesPage: function () { - Zotero.openInViewer("https://www.zotero.org/styles/", function (doc) { - // Hide header, intro paragraph, Link, and Source - // - // (The first two aren't sent to the client normally, but hide anyway in case they are.) - var style = doc.createElement('style'); - style.type = 'text/css'; - style.innerHTML = 'h1, #intro, .style-individual-link, .style-view-source { display: none !important; }' - // TEMP: Default UA styles that aren't being included in Firefox 60 for some reason - + 'html { background: #fff; }' - + 'a { color: rgb(0, 0, 238) !important; text-decoration: underline; }' - + 'a:active { color: rgb(238, 0, 0) !important; }'; - doc.getElementsByTagName('head')[0].appendChild(style); + Zotero.openInViewer("https://www.zotero.org/styles/", { + onLoad(doc) { + // Hide header, intro paragraph, Link, and Source + // + // (The first two aren't sent to the client normally, but hide anyway in case they are.) + var style = doc.createElement('style'); + style.type = 'text/css'; + style.innerHTML = 'h1, #intro, .style-individual-link, .style-view-source { display: none !important; }' + // TEMP: Default UA styles that aren't being included in Firefox 60 for some reason + + 'html { background: #fff; }' + + 'a { color: rgb(0, 0, 238) !important; text-decoration: underline; }' + + 'a:active { color: rgb(238, 0, 0) !important; }'; + doc.getElementsByTagName('head')[0].appendChild(style); + } }); }, diff --git a/chrome/content/zotero/preferences/preferences_cite.xhtml b/chrome/content/zotero/preferences/preferences_cite.xhtml index 9be73bdaa7..b4f1e4662a 100644 --- a/chrome/content/zotero/preferences/preferences_cite.xhtml +++ b/chrome/content/zotero/preferences/preferences_cite.xhtml @@ -61,10 +61,10 @@