From 5696ea239633151d5adb6fade0dfa8b2d7805d7e Mon Sep 17 00:00:00 2001 From: barisusakli Date: Tue, 9 Sep 2014 22:09:27 -0400 Subject: [PATCH] check errors on decodeURIComponent --- src/meta/title.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/meta/title.js b/src/meta/title.js index 652001af97..1de916ebec 100644 --- a/src/meta/title.js +++ b/src/meta/title.js @@ -1,6 +1,7 @@ 'use strict'; -var user = require('../user'), +var winston = require('winston'), + user = require('../user'), translator = require('../../public/src/translator'); module.exports = function(Meta) { @@ -14,7 +15,14 @@ module.exports = function(Meta) { }; 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) { title = Meta.config.browserTitle || 'NodeBB'; } else {