From 033af5091f6673f811e628c3258bc76d8fb5a3ef Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Thu, 8 Oct 2020 09:36:47 +0100 Subject: [PATCH] [SpellingAPIManager] get the list of ignored misspellings from settings The settings will allow overrides via the environment variable `IGNORED_MISSPELLINGS`. --- services/spelling/app/js/SpellingAPIManager.js | 3 ++- services/spelling/config/settings.defaults.js | 4 ++++ services/spelling/test/unit/js/SpellingAPIManagerTests.js | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/services/spelling/app/js/SpellingAPIManager.js b/services/spelling/app/js/SpellingAPIManager.js index e5e1c7896f..9a8dc1cc11 100644 --- a/services/spelling/app/js/SpellingAPIManager.js +++ b/services/spelling/app/js/SpellingAPIManager.js @@ -10,12 +10,13 @@ const ASpell = require('./ASpell') const LearnedWordsManager = require('./LearnedWordsManager') const { callbackify } = require('util') const OError = require('@overleaf/o-error') +const Settings = require('settings-sharelatex') // The max number of words checked in a single request const REQUEST_LIMIT = 10000 const SpellingAPIManager = { - whitelist: ['ShareLaTeX', 'sharelatex', 'LaTeX', 'http', 'https', 'www'], + whitelist: Settings.ignoredMisspellings, learnWord(token, request, callback) { if (callback == null) { diff --git a/services/spelling/config/settings.defaults.js b/services/spelling/config/settings.defaults.js index 702f39ec73..debb4225db 100644 --- a/services/spelling/config/settings.defaults.js +++ b/services/spelling/config/settings.defaults.js @@ -22,6 +22,10 @@ module.exports = { healthCheckUserId: '53c64d2fd68c8d000010bb5f', + ignoredMisspellings: process.env.IGNORED_MISSPELLINGS + ? process.env.IGNORED_MISSPELLINGS.split(',') + : ['ShareLaTeX', 'sharelatex', 'LaTeX', 'http', 'https', 'www'], + sentry: { dsn: process.env.SENTRY_DSN } diff --git a/services/spelling/test/unit/js/SpellingAPIManagerTests.js b/services/spelling/test/unit/js/SpellingAPIManagerTests.js index ab6ecf48a2..76d592720f 100644 --- a/services/spelling/test/unit/js/SpellingAPIManagerTests.js +++ b/services/spelling/test/unit/js/SpellingAPIManagerTests.js @@ -30,6 +30,7 @@ describe('SpellingAPIManager', function () { this.SpellingAPIManager = SandboxedModule.require(modulePath, { requires: { './ASpell': this.ASpell, + 'settings-sharelatex': { ignoredMisspellings: ['ShareLaTeX'] }, './LearnedWordsManager': this.LearnedWordsManager } })