Skip to content

Commit

Permalink
escape default text
Browse files Browse the repository at this point in the history
fixes #2314
  • Loading branch information
koenpunt committed Oct 11, 2016
1 parent 9e16752 commit 057f285
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion coffee/chosen.jquery.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,10 @@ class Chosen extends AbstractChosen
@search_field.val()

get_search_text: ->
$('<div/>').text($.trim(this.get_search_field_value())).html()
this.escape_html $.trim(this.get_search_field_value())

escape_html: (text) ->
$('<div/>').text(text).html()

winnow_results_set_highlight: ->
selected_results = if not @is_multiple then @search_results.find(".result-selected.active-result") else []
Expand Down
5 changes: 4 additions & 1 deletion coffee/chosen.proto.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ class @Chosen extends AbstractChosen
@search_field.value

get_search_text: ->
this.get_search_field_value().strip().escapeHTML()
this.escape_html this.get_search_field_value().strip()

escape_html: (text) ->
text.escapeHTML()

winnow_results_set_highlight: ->
if not @is_multiple
Expand Down
2 changes: 2 additions & 0 deletions coffee/lib/abstract-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class AbstractChosen
else
@default_text = @options.placeholder_text_single || @options.placeholder_text || AbstractChosen.default_single_text

@default_text = this.escape_html(@default_text)

@results_none_found = @form_field.getAttribute("data-no_results_text") || @options.no_results_text || AbstractChosen.default_no_result_text

choice_label: (item) ->
Expand Down

0 comments on commit 057f285

Please sign in to comment.