Avoid using html() to set languages description
The jQuery html() function does not filter <script> tags, so if somehow an attacker introduced a <script> in the translation, we would be vulnerable to a XSS attack. Note using $.parseHTML wouldn't solve the problem, since it doesn't filter attributes in image tags. Since changing the text of the part which doesn't have the count wasn't very clean, I've added another <span> tag for the part with the description, and so we can use jQuery's text() function to replace it.
This commit is contained in:
@@ -77,9 +77,10 @@
|
||||
update_description: function() {
|
||||
var count, description;
|
||||
count = App.Globalize.enabled_locales().length;
|
||||
description = App.Globalize.language_description(count);
|
||||
$(".js-languages-description").html(description);
|
||||
$(".js-languages-count").text(count);
|
||||
description = $(App.Globalize.language_description(count)).filter(".description").text();
|
||||
|
||||
$(".js-languages-description .description").text(description);
|
||||
$(".js-languages-description .count").text(count);
|
||||
},
|
||||
language_description: function(count) {
|
||||
switch (count) {
|
||||
|
||||
Reference in New Issue
Block a user