mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
Handle invalid JSON input in the theme settings editor (#1562)
* Handle invalid JSON input in the theme settings editor
This commit is contained in:
@@ -276,7 +276,15 @@ $(() => {
|
|||||||
|
|
||||||
$("#theme-settings-button").click(function() {
|
$("#theme-settings-button").click(function() {
|
||||||
let form = $("#theme-settings-modal form");
|
let form = $("#theme-settings-modal form");
|
||||||
let data = JSON.parse(theme_settings_editor.getValue());
|
let data;
|
||||||
|
|
||||||
|
// Ignore invalid JSON data
|
||||||
|
try {
|
||||||
|
data = JSON.parse(theme_settings_editor.getValue());
|
||||||
|
} catch (e) {
|
||||||
|
data = {};
|
||||||
|
}
|
||||||
|
|
||||||
$.each(data, function(key, value) {
|
$.each(data, function(key, value) {
|
||||||
var ctrl = form.find(`[name='${key}']`);
|
var ctrl = form.find(`[name='${key}']`);
|
||||||
switch (ctrl.prop("type")) {
|
switch (ctrl.prop("type")) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user