From 980e97ec2877d8152ba8db647346206668628ffa Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 10 Feb 2015 15:24:09 -0500 Subject: [PATCH] Merge pull request #3192 from riking/patch-xss SECURITY: missed html escaping --- .../discourse/controllers/composer.js.es6 | 16 ++++++++-------- app/models/topic.rb | 8 +------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6 index 9e2e43e8c6..71fb5c3cfb 100644 --- a/app/assets/javascripts/discourse/controllers/composer.js.es6 +++ b/app/assets/javascripts/discourse/controllers/composer.js.es6 @@ -135,11 +135,11 @@ export default DiscourseController.extend({ // for now handle a very narrow use case // if we are replying to a topic AND not on the topic pop the window up - if(!force && composer.get('replyingToTopic')) { + if (!force && composer.get('replyingToTopic')) { var topic = this.get('topic'); if (!topic || topic.get('id') !== composer.get('topic.id')) { - var message = I18n.t("composer.posting_not_on_topic", {title: this.get('model.topic.title')}); + var message = I18n.t("composer.posting_not_on_topic"); var buttons = [{ "label": I18n.t("composer.cancel"), @@ -147,11 +147,11 @@ export default DiscourseController.extend({ "link": true }]; - if(topic) { + if (topic) { buttons.push({ - "label": I18n.t("composer.reply_here") + "
" + topic.get('title') + "
", + "label": I18n.t("composer.reply_here") + "
" + Handlebars.Utils.escapeExpression(topic.get('title')) + "
", "class": "btn btn-reply-here", - "callback": function(){ + "callback": function() { composer.set('topic', topic); composer.set('post', null); self.save(true); @@ -160,14 +160,14 @@ export default DiscourseController.extend({ } buttons.push({ - "label": I18n.t("composer.reply_original") + "
" + this.get('model.topic.title') + "
", + "label": I18n.t("composer.reply_original") + "
" + Handlebars.Utils.escapeExpression(this.get('model.topic.title')) + "
", "class": "btn-primary btn-reply-on-original", - "callback": function(){ + "callback": function() { self.save(true); } }); - bootbox.dialog(message, buttons, {"classes": "reply-where-modal"}); + bootbox.dialog(message, buttons, { "classes": "reply-where-modal" }); return; } } diff --git a/app/models/topic.rb b/app/models/topic.rb index 9eae898bb3..85f3eb196f 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -254,13 +254,7 @@ class Topic < ActiveRecord::Base end def fancy_title - sanitized_title = title.gsub(/['&\"<>]/, { - "'" => ''', - '&' => '&', - '"' => '"', - '<' => '<', - '>' => '>', - }) + sanitized_title = ERB::Util.html_escape(title) return unless sanitized_title return sanitized_title unless SiteSetting.title_fancy_entities?