From ffa2bd14f85929e7fa08eb5badfa8d9cb155e4ef Mon Sep 17 00:00:00 2001 From: Peter Jaszkowiak Date: Sat, 7 Jan 2017 22:48:57 -0700 Subject: [PATCH] Fix reverse proxies breaking admin translations --- public/src/modules/translator.js | 2 +- src/middleware/index.js | 2 +- src/routes/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/public/src/modules/translator.js b/public/src/modules/translator.js index 0c960f2234..e4d74b5508 100644 --- a/public/src/modules/translator.js +++ b/public/src/modules/translator.js @@ -3,7 +3,7 @@ (function (factory) { 'use strict'; function loadClient(language, namespace) { - return Promise.resolve(jQuery.getJSON(config.relative_path + '/api/language/' + language + '/' + encodeURIComponent(namespace))); + return Promise.resolve(jQuery.getJSON(config.relative_path + '/api/language/' + language + '/' + namespace)); } var warn = function () {}; if (typeof config === 'object' && config.environment === 'development') { diff --git a/src/middleware/index.js b/src/middleware/index.js index 9bf02c1449..f48aaef748 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -185,7 +185,7 @@ middleware.applyBlacklist = function (req, res, next) { middleware.getTranslation = function (req, res, next) { var language = req.params.language; - var namespace = req.params.namespace; + var namespace = req.params[0]; if (language && namespace) { languages.get(language, namespace, function (err, translations) { diff --git a/src/routes/index.js b/src/routes/index.js index e9943e0dae..863715008e 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -144,7 +144,7 @@ module.exports = function (app, middleware, hotswapIds) { } app.use(middleware.privateUploads); - app.use(relativePath + '/api/language/:language/:namespace', middleware.getTranslation); + app.use(relativePath + '/api/language/:language/(([a-zA-Z0-9\\-_.\\/]+))', middleware.getTranslation); app.use(relativePath, express.static(path.join(__dirname, '../../', 'public'), { maxAge: app.enabled('cache') ? 5184000000 : 0 }));