Commit d7754696 authored by Heinrich Fenkart's avatar Heinrich Fenkart

Customizer: Remove file type check from config import

Fixes #14978.
parent 03834866
...@@ -361,20 +361,15 @@ window.onload = function () { // wait for load in a dumb way because B-0 ...@@ -361,20 +361,15 @@ window.onload = function () { // wait for load in a dumb way because B-0
var file = (e.originalEvent.hasOwnProperty('dataTransfer')) ? e.originalEvent.dataTransfer.files[0] : e.originalEvent.target.files[0] var file = (e.originalEvent.hasOwnProperty('dataTransfer')) ? e.originalEvent.dataTransfer.files[0] : e.originalEvent.target.files[0]
if (!file.type.match('application/json')) {
return showAlert('danger', '<strong>Ruh roh.</strong> We can only read <code>.json</code> files. Please try again.', importDropTarget)
}
var reader = new FileReader() var reader = new FileReader()
reader.onload = (function () { reader.onload = function (e) {
return function (e) {
var text = e.target.result var text = e.target.result
try { try {
var json = JSON.parse(text) var json = JSON.parse(text)
if (typeof json != 'object') { if (!$.isPlainObject(json)) {
throw new Error('JSON data from config file is not an object.') throw new Error('JSON data from config file is not an object.')
} }
...@@ -384,9 +379,8 @@ window.onload = function () { // wait for load in a dumb way because B-0 ...@@ -384,9 +379,8 @@ window.onload = function () { // wait for load in a dumb way because B-0
return showAlert('danger', '<strong>Shucks.</strong> We can only read valid <code>.json</code> files. Please try again.', importDropTarget) return showAlert('danger', '<strong>Shucks.</strong> We can only read valid <code>.json</code> files. Please try again.', importDropTarget)
} }
} }
})(file)
reader.readAsText(file) reader.readAsText(file, 'utf-8')
} }
function handleConfigDragOver(e) { function handleConfigDragOver(e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment