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