check errors on decodeURIComponent

v1.18.x
barisusakli 11 years ago
parent 0b79a73732
commit 5696ea2396

@ -1,6 +1,7 @@
'use strict'; 'use strict';
var user = require('../user'), var winston = require('winston'),
user = require('../user'),
translator = require('../../public/src/translator'); translator = require('../../public/src/translator');
module.exports = function(Meta) { module.exports = function(Meta) {
@ -14,7 +15,14 @@ module.exports = function(Meta) {
}; };
Meta.title.build = function (urlFragment, language, callback) { Meta.title.build = function (urlFragment, language, callback) {
Meta.title.parseFragment(decodeURIComponent(urlFragment), language, function(err, title) { var uri = '';
try {
uri = decodeURIComponent(urlFragment);
} catch(e) {
winston.error('Invalid url fragment :' + urlFragment);
return callback(null, Meta.config.browserTitle || 'NodeBB');
}
Meta.title.parseFragment(uri, language, function(err, title) {
if (err) { if (err) {
title = Meta.config.browserTitle || 'NodeBB'; title = Meta.config.browserTitle || 'NodeBB';
} else { } else {

Loading…
Cancel
Save