mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
web: Do not assume error responses are valid, or our, JSON.
Partially fixes #24815.
This commit is contained in:
committed by
Tim Abbott
parent
7efe989a72
commit
ba7492a314
@@ -583,10 +583,14 @@ export function initialize() {
|
||||
$invite_row.remove();
|
||||
}
|
||||
|
||||
function failure(error_msg) {
|
||||
function xhr_failure(xhr) {
|
||||
let error_message = "Failed to subscribe user!";
|
||||
if (xhr.responseJSON?.msg) {
|
||||
error_message = xhr.responseJSON.msg;
|
||||
}
|
||||
clear_invites();
|
||||
compose_banner.show_error_message(
|
||||
error_msg,
|
||||
error_message,
|
||||
compose_banner.CLASSNAMES.generic_compose_error,
|
||||
$banner_container,
|
||||
$("#compose-textarea"),
|
||||
@@ -594,11 +598,6 @@ export function initialize() {
|
||||
$(event.target).prop("disabled", true);
|
||||
}
|
||||
|
||||
function xhr_failure(xhr) {
|
||||
const error = xhr.responseJSON;
|
||||
failure(error.msg);
|
||||
}
|
||||
|
||||
const sub = sub_store.get(stream_id);
|
||||
|
||||
subscriber_api.add_user_ids_to_stream([user_id], sub, success, xhr_failure);
|
||||
|
||||
Reference in New Issue
Block a user