From 393c89142179454d731931e85399685237f2a1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Sun, 24 Jul 2022 22:22:28 +0200 Subject: [PATCH] Fix handling of internal errors when uploading theming files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a file can not be uploaded in the Theming app due to an expected error (like an invalid mime type) the response contains a "data.message" field. However, if the upload fails due to an unexpected error (like an internal error, for example if the "mime_content_type" function is disabled) there is no such field, so it should not be used. Signed-off-by: Daniel Calviño Sánchez --- apps/theming/js/settings-admin.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js index 7efdab6dda47c..0c18db1c9f411 100644 --- a/apps/theming/js/settings-admin.js +++ b/apps/theming/js/settings-admin.js @@ -127,7 +127,8 @@ window.addEventListener('DOMContentLoaded', function () { }, fail: function (e, response){ var $form = $(e.target).closest('form'); - OC.msg.finishedError('#theming_settings_msg', response._response.jqXHR.responseJSON.data.message); + const responseJSON = response._response.jqXHR.responseJSON; + OC.msg.finishedError('#theming_settings_msg', responseJSON && responseJSON.data && responseJSON.data.message ? responseJSON.data.message : t('theming', 'Error uploading the file')); $form.find('label.button').addClass('icon-upload').removeClass('icon-loading-small'); $('#theming_settings_loading').hide(); }