mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-26 15:56:30 +01:00
sanity checks for JS fetch errors
Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
@@ -99,7 +99,7 @@ export default class Updates {
|
||||
if (!this.payload.resources.total) { return this; }
|
||||
|
||||
[plugins, themes].forEach(function(resources, index) {
|
||||
if (!resources || Array.isArray(resources)) { return; }
|
||||
if (!resources || Array.isArray(resources) || typeof resources !== 'object') { return; }
|
||||
let length = Object.keys(resources).length;
|
||||
let type = map[index];
|
||||
|
||||
|
||||
@@ -12,7 +12,9 @@ let request = function(url, options = {}, callback = () => true) {
|
||||
let data = new FormData();
|
||||
|
||||
options.body = Object.assign({ 'admin-nonce': config.admin_nonce }, options.body || {});
|
||||
if (options.body && typeof options.body === 'object') {
|
||||
Object.keys(options.body).map((key) => data.append(key, options.body[key]));
|
||||
}
|
||||
options.body = data;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ export function userFeedback(response) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (settings) {
|
||||
if (settings && typeof settings === 'object' && settings !== null) {
|
||||
backup = Object.assign({}, toastr.options);
|
||||
Object.keys(settings).forEach((key) => { toastr.options[key] = settings[key]; });
|
||||
}
|
||||
|
||||
14
themes/grav/js/admin.min.js
vendored
14
themes/grav/js/admin.min.js
vendored
@@ -704,6 +704,7 @@ const external_GravAdmin_namespaceObject = GravAdmin;
|
||||
var trim = __webpack_require__(35814);
|
||||
var trim_default = /*#__PURE__*/__webpack_require__.n(trim);
|
||||
;// CONCATENATED MODULE: ./app/utils/response.js
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
|
||||
|
||||
|
||||
@@ -770,7 +771,7 @@ function userFeedback(response) {
|
||||
message = message || 'Invalid AJAX response.';
|
||||
break;
|
||||
}
|
||||
if (settings) {
|
||||
if (settings && _typeof(settings) === 'object' && settings !== null) {
|
||||
backup = Object.assign({}, utils_toastr.options);
|
||||
Object.keys(settings).forEach(function (key) {
|
||||
utils_toastr.options[key] = settings[key];
|
||||
@@ -796,6 +797,7 @@ external_jQuery_default()(__webpack_require__.g).on('beforeunload._ajax', functi
|
||||
UNLOADING = true;
|
||||
});
|
||||
;// CONCATENATED MODULE: ./app/utils/request.js
|
||||
function request_typeof(o) { "@babel/helpers - typeof"; return request_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, request_typeof(o); }
|
||||
|
||||
|
||||
var raw;
|
||||
@@ -813,9 +815,11 @@ var request = function request(url) {
|
||||
options.body = Object.assign({
|
||||
'admin-nonce': external_GravAdmin_namespaceObject.config.admin_nonce
|
||||
}, options.body || {});
|
||||
if (options.body && request_typeof(options.body) === 'object') {
|
||||
Object.keys(options.body).map(function (key) {
|
||||
return data.append(key, options.body[key]);
|
||||
});
|
||||
}
|
||||
options.body = data;
|
||||
}
|
||||
options = Object.assign({
|
||||
@@ -833,12 +837,12 @@ var request = function request(url) {
|
||||
};
|
||||
/* harmony default export */ const utils_request = (request);
|
||||
;// CONCATENATED MODULE: ./app/forms/fields/files.js
|
||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
||||
function files_typeof(o) { "@babel/helpers - typeof"; return files_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, files_typeof(o); }
|
||||
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
||||
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
||||
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == files_typeof(i) ? i : i + ""; }
|
||||
function _toPrimitive(t, r) { if ("object" != files_typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != files_typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
||||
|
||||
|
||||
// import EXIF from 'exif-js';
|
||||
@@ -1830,7 +1834,7 @@ var Updates = /*#__PURE__*/function () {
|
||||
return this;
|
||||
}
|
||||
[plugins, themes].forEach(function (resources, index) {
|
||||
if (!resources || Array.isArray(resources)) {
|
||||
if (!resources || Array.isArray(resources) || updates_typeof(resources) !== 'object') {
|
||||
return;
|
||||
}
|
||||
var length = Object.keys(resources).length;
|
||||
|
||||
Reference in New Issue
Block a user