Skip to content

Commit

Permalink
fix XSS vulnerability
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Best committed Apr 17, 2017
1 parent 0cbecb2 commit 5a49e06
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 8 deletions.
17 changes: 15 additions & 2 deletions lib/js/emoji-picker.coffee
Expand Up @@ -62,11 +62,24 @@ class @EmojiPicker
else
''

unicodeToImage:(input) ->
appendUnicodeAsImageToElement:(element, input) ->
if !input
return ''
if !Config.rx_codes
Config.init_unified()

split_on_unicode = input.split(Config.rx_codes)
for text in split_on_unicode
val = ''
if Config.rx_codes.test(text)
val = Config.reversemap[text]
if val
val = ':' + val + ':'
val = $.emojiarea.createIcon($.emojiarea.icons[val])
else
val = document.createTextNode(text)
element.append(val)

input.replace Config.rx_codes, (m) ->
val = Config.reversemap[m]
if val
Expand All @@ -86,4 +99,4 @@ class @EmojiPicker
$img = $.emojiarea.createIcon($.emojiarea.icons[m])
$img
else
''
''
27 changes: 24 additions & 3 deletions lib/js/emoji-picker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/js/emoji-picker.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/js/jquery.emojiarea.js
Expand Up @@ -343,8 +343,8 @@
if ($textarea.attr('maxlength')) {
this.$editor.attr('maxlength', $textarea.attr('maxlength'));
}
var unicodeToImageText = this.emojiPopup.unicodeToImage($textarea.val());
this.$editor.html(unicodeToImageText);
this.emojiPopup.appendUnicodeAsImageToElement(this.$editor, $textarea.val());

this.$editor.attr({
'data-id': id,
'data-type': 'input',
Expand Down

0 comments on commit 5a49e06

Please sign in to comment.