diff --git a/core/client/views/editor-tag-widget.js b/core/client/views/editor-tag-widget.js index aa12f468ed..901cf3b7f0 100644 --- a/core/client/views/editor-tag-widget.js +++ b/core/client/views/editor-tag-widget.js @@ -45,7 +45,7 @@ if (tags) { _.forEach(tags, function (tag) { - var $tag = $('' + tag.name + ''); + var $tag = $('' + _.escape(tag.name) + ''); $tags.append($tag); $("[data-tag-id=" + tag.id + "]")[0].scrollIntoView(true); }); @@ -120,11 +120,14 @@ _.each(matchingTags, function (matchingTag) { var highlightedName, suggestionHTML; - - highlightedName = matchingTag.name.replace(regexPattern, "$1"); + highlightedName = matchingTag.name.replace(regexPattern, function (match, p1) { + return "" + _.escape(p1) + ""; + }); /*jslint regexp: true */ // - would like to remove this - highlightedName = highlightedName.replace(/([^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, "$1$2$4"); - + highlightedName = highlightedName.replace(/([^<>]*)((<[^>]+>)+)([^<>]*<\/mark>)/, function (match, p1, p2, p3, p4) { + return _.escape(p1) + '' + _.escape(p2) + '' + _.escape(p4); + }); + suggestionHTML = "
  • " + highlightedName + "
  • "; this.$suggestions.append(suggestionHTML); }, this); @@ -277,7 +280,7 @@ }, addTag: function (tag) { - var $tag = $('' + tag.name + ''); + var $tag = $('' + _.escape(tag.name) + ''); this.$('.tags').append($tag); $(".tag").last()[0].scrollIntoView(true); window.scrollTo(0, 1);