From 94ceee3c7e5e7ee00ded4c1471467c605f46e83b Mon Sep 17 00:00:00 2001 From: Mm2PL Date: Tue, 14 Feb 2023 11:55:55 +0100 Subject: [PATCH] Handle info.json homepage type mismatches --- src/controllers/plugins/Plugin.hpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/controllers/plugins/Plugin.hpp b/src/controllers/plugins/Plugin.hpp index 8a35b3312..9ebfd999b 100644 --- a/src/controllers/plugins/Plugin.hpp +++ b/src/controllers/plugins/Plugin.hpp @@ -51,8 +51,21 @@ struct PluginMeta { } explicit PluginMeta(const QJsonObject &obj) - : homepage(obj.value("homepage").toString("")) { + auto homepageObj = obj.value("homepage"); + if (homepageObj.isString()) + { + this->homepage = homepageObj.toString(); + } + else if (!homepageObj.isUndefined()) + { + auto type = QString::fromStdString( + std::string(magic_enum::enum_name(homepageObj.type()))); + this->errors.emplace_back( + QString( + "homepage is defined but is not a string (its type is %1)") + .arg(type)); + } auto nameObj = obj.value("name"); if (nameObj.isString()) {