Skip to content

Commit 057f285

Browse files
committed
escape default text
fixes #2314
1 parent 9e16752 commit 057f285

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

coffee/chosen.jquery.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,10 @@ class Chosen extends AbstractChosen
406406
@search_field.val()
407407

408408
get_search_text: ->
409-
$('<div/>').text($.trim(this.get_search_field_value())).html()
409+
this.escape_html $.trim(this.get_search_field_value())
410+
411+
escape_html: (text) ->
412+
$('<div/>').text(text).html()
410413

411414
winnow_results_set_highlight: ->
412415
selected_results = if not @is_multiple then @search_results.find(".result-selected.active-result") else []

coffee/chosen.proto.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,10 @@ class @Chosen extends AbstractChosen
396396
@search_field.value
397397

398398
get_search_text: ->
399-
this.get_search_field_value().strip().escapeHTML()
399+
this.escape_html this.get_search_field_value().strip()
400+
401+
escape_html: (text) ->
402+
text.escapeHTML()
400403

401404
winnow_results_set_highlight: ->
402405
if not @is_multiple

coffee/lib/abstract-chosen.coffee

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class AbstractChosen
4545
else
4646
@default_text = @options.placeholder_text_single || @options.placeholder_text || AbstractChosen.default_single_text
4747

48+
@default_text = this.escape_html(@default_text)
49+
4850
@results_none_found = @form_field.getAttribute("data-no_results_text") || @options.no_results_text || AbstractChosen.default_no_result_text
4951

5052
choice_label: (item) ->

0 commit comments

Comments
 (0)