mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 01:23:48 +01:00
Fix potentiall XSS vulnerability
This commit is contained in:
parent
63af1535b9
commit
ca7708437b
@ -22,14 +22,22 @@
|
||||
{% endfor %}
|
||||
]
|
||||
|
||||
function escape(unsafe) {
|
||||
return unsafe
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
all_packages = meta_packages.slice();
|
||||
|
||||
{% for p in packages %}
|
||||
{# This is safe as name can only contain `[a-z0-9_]` #}
|
||||
all_packages.push({
|
||||
id: "{{ p.author.username }}/{{ p.name }}",
|
||||
value: {{ p.title | tojson }} + " by " + {{ p.author.display_name | tojson }},
|
||||
toString: function() { return {{ p.title | tojson }} + " by " + {{ p.author.display_name | tojson }} + " only"; },
|
||||
value: escape({{ p.title | tojson }} + " by " + {{ p.author.display_name | tojson }}),
|
||||
toString: function() { return escape({{ p.title | tojson }} + " by " + {{ p.author.display_name | tojson }} + " only"); },
|
||||
});
|
||||
{% endfor %}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user