mirror of
https://github.com/zotero/zotero.git
synced 2026-11-27 23:58:57 +00:00
The list of blocked plugins is now published on the server instead of being hard-coded in the client, and the build fetches the published copy into the app as the built-in list. At launch, the client requests the published copy and waits up to a second for it before loading plugins, so that a newly blocked plugin isn't started. If it doesn't arrive in time, the built-in or cached copy is used and the download is applied when it arrives. The list is also downloaded when the streaming server sends a notification, when the client reconnects to the streaming server, and every 6 hours while not connected. Whichever copy has the higher version is used. A plugin that's blocked while running is immediately shut down.
32 lines
1.2 KiB
Bash
Executable file
32 lines
1.2 KiB
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Replace the built-in plugin blocklist with the published one
|
|
#
|
|
# Usage: fetch_plugin_blocklist FILE
|
|
|
|
URL="https://plugins.zotero.org/blocked-plugins.json"
|
|
|
|
file="$1"
|
|
tmp_file="$file.tmp"
|
|
|
|
curl -sSf --retry 3 "$URL" -o "$tmp_file"
|
|
python3 -c '
|
|
import json, sys
|
|
with open(sys.argv[1]) as f:
|
|
data = json.load(f)
|
|
version = data.get("version")
|
|
if not isinstance(version, int) or isinstance(version, bool) or not isinstance(data.get("blockedPlugins"), list):
|
|
raise Exception("Invalid plugin blocklist")
|
|
for plugin in data["blockedPlugins"]:
|
|
if not isinstance(plugin.get("id"), str) or not isinstance(plugin.get("versionRanges"), list):
|
|
raise Exception("Invalid plugin blocklist entry: " + json.dumps(plugin))
|
|
for r in plugin["versionRanges"]:
|
|
if not isinstance(r, dict) or any(k in r and not isinstance(r[k], str) for k in ("minVersion", "maxVersion")):
|
|
raise Exception("Invalid version range for blocked plugin " + plugin["id"])
|
|
with open(sys.argv[2], "w") as f:
|
|
json.dump(data, f, indent="\t")
|
|
f.write("\n")
|
|
print("Fetched plugin blocklist version {} with {} entries".format(version, len(data["blockedPlugins"])))
|
|
' "$tmp_file" "$file"
|
|
rm "$tmp_file"
|