1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Fix plugin loading when browser sends unrecognised lang

This commit is contained in:
Nick O'Leary 2021-05-11 16:42:00 +01:00
parent ade318bb78
commit d8d384a979
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
2 changed files with 5 additions and 7 deletions

View File

@ -17,9 +17,8 @@ module.exports = {
}) })
} else { } else {
opts.lang = apiUtils.determineLangFromHeaders(req.acceptsLanguages()); opts.lang = apiUtils.determineLangFromHeaders(req.acceptsLanguages());
if (/[^a-z\-\*]/i.test(opts.lang)) { if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
res.json({}); opts.lang = "en-US";
return;
} }
runtimeAPI.plugins.getPluginConfigs(opts).then(function(configs) { runtimeAPI.plugins.getPluginConfigs(opts).then(function(configs) {
res.send(configs); res.send(configs);
@ -32,9 +31,8 @@ module.exports = {
lang: req.query.lng, lang: req.query.lng,
req: apiUtils.getRequestLogObject(req) req: apiUtils.getRequestLogObject(req)
} }
if (/[^a-z\-\*]/i.test(opts.lang)) { if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
res.json({}); opts.lang = "en-US";
return;
} }
runtimeAPI.plugins.getPluginCatalogs(opts).then(function(result) { runtimeAPI.plugins.getPluginCatalogs(opts).then(function(result) {
res.json(result); res.json(result);

View File

@ -58,7 +58,7 @@ var api = module.exports = {
* @memberof @node-red/runtime_plugins * @memberof @node-red/runtime_plugins
*/ */
getPluginConfigs: async function(opts) { getPluginConfigs: async function(opts) {
if (/[^a-z\-]/i.test(opts.lang)) { if (/[^0-9a-z=\-\*]/i.test(opts.lang)) {
throw new Error("Invalid language: "+opts.lang) throw new Error("Invalid language: "+opts.lang)
return; return;
} }