Add pref to enable local API (#4236)

And keep enabled in tests
This commit is contained in:
Abe Jellinek 2024-06-14 06:25:39 -04:00 committed by GitHub
parent 17539404b2
commit 50e2250fe0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 10 additions and 0 deletions

View file

@ -35,6 +35,8 @@
</html:div>
<checkbox label="&zotero.preferences.reportTranslationFailure;" preference="extensions.zotero.reportTranslationFailure" native="true"/>
<checkbox data-l10n-id="preferences-advanced-enable-local-api" preference="extensions.zotero.httpServer.localAPI.enabled" native="true"/>
</groupbox>
<groupbox>

View file

@ -87,6 +87,10 @@ const exportFormats = new Map([
*/
class LocalAPIEndpoint {
async init(requestData) {
if (!Zotero.Prefs.get('httpServer.localAPI.enabled')) {
return this.makeResponse(403, 'text/plain', 'Local API is not enabled');
}
let apiVersion = parseInt(
requestData.headers['Zotero-API-Version']
|| requestData.searchParams.get('v')

View file

@ -56,6 +56,8 @@ preferences-styleManager-add-button =
.tooltiptext = Add a style from a file
.label = { $label }
preferences-advanced-enable-local-api =
.label = Allow other applications on this computer to communicate with { -app-name }
preferences-advanced-language-and-region-title = Language and Region
preferences-advanced-enable-bidi-ui =
.label = Enable bidirectional text editing utilities

View file

@ -144,6 +144,7 @@ pref("extensions.zotero.integration.dontPromptMendeleyImport", false);
// Connector settings
pref("extensions.zotero.httpServer.enabled", true);
pref("extensions.zotero.httpServer.port", 23119); // ascii "ZO"
pref("extensions.zotero.httpServer.localAPI.enabled", false);
// Zeroconf
pref("extensions.zotero.zeroconf.server.enabled", false);

View file

@ -137,6 +137,7 @@ user_pref("extensions.zotero.firstRunGuidance", false);
user_pref("extensions.zotero.firstRun2", false);
user_pref("extensions.zotero.reportTranslationFailure", false);
user_pref("extensions.zotero.httpServer.enabled", true);
user_pref("extensions.zotero.httpServer.localAPI.enabled", true);
user_pref("extensions.zotero.backup.numBackups", 0);
user_pref("extensions.zotero.sync.autoSync", false);
user_pref("extensions.zoteroMacWordIntegration.installed", true);