Move referercheck earlier so it doesnt break since i18n, and add a form validation to prevent referer check getting into an invalid state with empty hosts

merge-requests/341/head
Thomas Lynch 1 year ago
parent 28f9afa0c1
commit f3f972a4a4
  1. 1
      CHANGELOG.md
  2. 3
      controllers/forms/globalsettings.js
  3. 3
      locales/en-GB.json
  4. 3
      locales/pt-PT.json
  5. 3
      locales/ru-RU.json
  6. 8
      server.js

@ -5,6 +5,7 @@
- Make animated webp thumbnailing at least work and not give the above error (not supporting animated thumbs like .gif yet).
- Add "ttf" extension to nginx snippets because some themes include fonts.
- Reorganize <input> styling, use accent-color property on <input> elements, by @disco.
- Fix an issue with the referer because of translation, and prevent invalid settings for it from breaking the web panel.
- Npm audit.
### 1.0.4

@ -8,7 +8,7 @@ const changeGlobalSettings = require(__dirname+'/../../models/forms/changeglobal
, paramConverter = require(__dirname+'/../../lib/middleware/input/paramconverter.js')
, i18n = require(__dirname+'/../../lib/locale/locale.js')
, { checkSchema, lengthBody, numberBody, minmaxBody, numberBodyVariable,
inArrayBody } = require(__dirname+'/../../lib/input/schema.js');
inArrayBody, existsBody } = require(__dirname+'/../../lib/input/schema.js');
module.exports = {
@ -73,6 +73,7 @@ module.exports = {
}
return false;
}, expected: true, error: __('Invalid reverse image search links URL format, must be a link containing %s where the url param belongs.') },
{ result: existsBody(req.body.referrer_check) ? lengthBody(req.body.allowed_hosts, 1) : false, expected: false, error: __('Please enter at least one allowed host in the "Allowed Hosts" field when the "Referer Check" option is selected.') },
{ result: numberBody(req.body.inactive_account_time), expected: true, error: __('Invalid inactive account time') },
{ result: numberBody(req.body.inactive_account_action, 0, 2), expected: true, error: __('Inactive account action must be a number from 0-2') },
{ result: numberBody(req.body.abandoned_board_action, 0, 3), expected: true, error: __('Abandoned board action must be a number from 0-3') },

@ -1393,5 +1393,6 @@
"View the full text": "View the full text",
"View the full thread": "View the full thread",
"%s earlier": "%s earlier",
"Lock+Unlist board": "Lock+Unlist board"
"Lock+Unlist board": "Lock+Unlist board",
"Please enter at least one allowed host in the \"Allowed Hosts\" field when the \"Referer Check\" option is selected.": "Please enter at least one allowed host in the \"Allowed Hosts\" field when the \"Referer Check\" option is selected."
}

@ -1393,5 +1393,6 @@
"View the full text": "Ver texto completo",
"View the full thread": "Ver fio completo",
"%s earlier": "%s anteriores",
"Lock+Unlist board": "Trancar+Remover da lista"
"Lock+Unlist board": "Trancar+Remover da lista",
"Please enter at least one allowed host in the \"Allowed Hosts\" field when the \"Referer Check\" option is selected.": "Por favor insere pelo menos um host permitido no campo de \"Hosts Permitidos\" quando a opção de \"Verificar Referer\" está selecionada."
}

@ -1393,5 +1393,6 @@
"View the full text": "Просмотреть полный текст",
"View the full thread": "Просмотреть полную ветку",
"%s earlier": "%s выше",
"Lock+Unlist board": "замок+исключить из списка"
"Lock+Unlist board": "замок+исключить из списка",
"Please enter at least one allowed host in the \"Allowed Hosts\" field when the \"Referer Check\" option is selected.": "Пожалуйста, введите хотя бы один разрешенный хост в поле \"Разрешенные хосты\", когда выбрана опция \"Проверка реферера\"."
}

@ -61,10 +61,6 @@ const config = require(__dirname+'/lib/misc/config.js')
//trust proxy for nginx
app.set('trust proxy', 1);
//self explanatory middlewares
const referrerCheck = require(__dirname+'/lib/middleware/misc/referrercheck.js');
app.use(referrerCheck);
// use pug view engine
const views = path.join(__dirname, 'views/pages');
app.set('view engine', 'pug');
@ -111,6 +107,10 @@ const config = require(__dirname+'/lib/misc/config.js')
app.use(i18n.init);
app.use(setGlobalLanguage);
//referer check middleware
const referrerCheck = require(__dirname+'/lib/middleware/misc/referrercheck.js');
app.use(referrerCheck);
app.use('/forms', require(__dirname+'/controllers/forms.js'));
app.use('/', require(__dirname+'/controllers/pages.js'));

Loading…
Cancel
Save