Fix XSS issue in AJAX example
This commit is contained in:
parent
1c394a421b
commit
1f79acbe5f
@ -309,7 +309,6 @@ $(".js-example-data-ajax").select2({
|
|||||||
cache: true
|
cache: true
|
||||||
},
|
},
|
||||||
placeholder: 'Search for a repository',
|
placeholder: 'Search for a repository',
|
||||||
escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
|
|
||||||
minimumInputLength: 1,
|
minimumInputLength: 1,
|
||||||
templateResult: formatRepo,
|
templateResult: formatRepo,
|
||||||
templateSelection: formatRepoSelection
|
templateSelection: formatRepoSelection
|
||||||
@ -320,23 +319,28 @@ function formatRepo (repo) {
|
|||||||
return repo.text;
|
return repo.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
var markup = "<div class='select2-result-repository clearfix'>" +
|
var $container = $(
|
||||||
|
"<div class='select2-result-repository clearfix'>" +
|
||||||
"<div class='select2-result-repository__avatar'><img src='" + repo.owner.avatar_url + "' /></div>" +
|
"<div class='select2-result-repository__avatar'><img src='" + repo.owner.avatar_url + "' /></div>" +
|
||||||
"<div class='select2-result-repository__meta'>" +
|
"<div class='select2-result-repository__meta'>" +
|
||||||
"<div class='select2-result-repository__title'>" + repo.full_name + "</div>";
|
"<div class='select2-result-repository__title'></div>" +
|
||||||
|
"<div class='select2-result-repository__description'></div>" +
|
||||||
if (repo.description) {
|
"<div class='select2-result-repository__statistics'>" +
|
||||||
markup += "<div class='select2-result-repository__description'>" + repo.description + "</div>";
|
"<div class='select2-result-repository__forks'><i class='fa fa-flash'></i> </div>" +
|
||||||
}
|
"<div class='select2-result-repository__stargazers'><i class='fa fa-star'></i> </div>" +
|
||||||
|
"<div class='select2-result-repository__watchers'><i class='fa fa-eye'></i> </div>" +
|
||||||
markup += "<div class='select2-result-repository__statistics'>" +
|
|
||||||
"<div class='select2-result-repository__forks'><i class='fa fa-flash'></i> " + repo.forks_count + " Forks</div>" +
|
|
||||||
"<div class='select2-result-repository__stargazers'><i class='fa fa-star'></i> " + repo.stargazers_count + " Stars</div>" +
|
|
||||||
"<div class='select2-result-repository__watchers'><i class='fa fa-eye'></i> " + repo.watchers_count + " Watchers</div>" +
|
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"</div></div>";
|
"</div>" +
|
||||||
|
"</div>"
|
||||||
|
);
|
||||||
|
|
||||||
return markup;
|
$container.find(".select2-result-repository__title").text(repo.full_name);
|
||||||
|
$container.find(".select2-result-repository__description").text(repo.description);
|
||||||
|
$container.find(".select2-result-repository__forks").append(repo.forks_count + " Forks");
|
||||||
|
$container.find(".select2-result-repository__stargazers").append(repo.stargazers_count + " Stars");
|
||||||
|
$container.find(".select2-result-repository__watchers").append(repo.watchers_count + " Watchers");
|
||||||
|
|
||||||
|
return $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatRepoSelection (repo) {
|
function formatRepoSelection (repo) {
|
||||||
|
Loading…
Reference in New Issue
Block a user