mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
ui_report: Fix HTML escaping of &.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
committed by
Tim Abbott
parent
c0822739d0
commit
b3caa79f35
@@ -21,20 +21,11 @@ exports.message = function (response, status_box, cls, remove_after) {
|
||||
status_box.addClass("show");
|
||||
};
|
||||
|
||||
function escape(html) {
|
||||
return html
|
||||
.toString()
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''');
|
||||
}
|
||||
|
||||
exports.error = function (response, xhr, status_box) {
|
||||
if (xhr && xhr.status.toString().charAt(0) === "4") {
|
||||
// Only display the error response for 4XX, where we've crafted
|
||||
// a nice response.
|
||||
const server_response = escape(JSON.parse(xhr.responseText).msg);
|
||||
const server_response = _.escape(JSON.parse(xhr.responseText).msg);
|
||||
if (response) {
|
||||
response += ": " + server_response;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user