diff --git a/es-core/src/components/ImageComponent.cpp b/es-core/src/components/ImageComponent.cpp index cc069634d..2d13b6ce0 100644 --- a/es-core/src/components/ImageComponent.cpp +++ b/es-core/src/components/ImageComponent.cpp @@ -555,6 +555,32 @@ void ImageComponent::applyTheme(const std::shared_ptr& theme, } imageTypes = Utils::String::replace(imageTypes, ",,", ","); mThemeImageTypes = Utils::String::delimitedStringToVector(imageTypes, ","); + + if (mThemeImageTypes.empty()) { + LOG(LogError) << "ImageComponent: Invalid theme configuration, property " + "contains no values"; + } + + for (std::string& type : mThemeImageTypes) { + if (std::find(supportedImageTypes.cbegin(), supportedImageTypes.cend(), type) == + supportedImageTypes.cend()) { + LOG(LogError) + << "ImageComponent: Invalid theme configuration, property " + "defined as \"" + << type << "\""; + mThemeImageTypes.clear(); + break; + } + } + + std::vector sortedTypes {mThemeImageTypes}; + std::stable_sort(sortedTypes.begin(), sortedTypes.end()); + + if (std::adjacent_find(sortedTypes.begin(), sortedTypes.end()) != sortedTypes.end()) { + LOG(LogError) << "ImageComponent: Invalid theme configuration, property " + "contains duplicate values"; + mThemeImageTypes.clear(); + } } if (elem->has("metadataElement") && elem->get("metadataElement")) diff --git a/es-core/src/components/ImageComponent.h b/es-core/src/components/ImageComponent.h index 1849f149a..da6857008 100644 --- a/es-core/src/components/ImageComponent.h +++ b/es-core/src/components/ImageComponent.h @@ -128,6 +128,10 @@ private: std::string mDefaultPath; + static inline std::vector supportedImageTypes { + "image", "miximage", "marquee", "screenshot", "titlescreen", + "cover", "backcover", "3dbox", "physicalmedia", "fanart"}; + std::shared_ptr mTexture; float mFadeOpacity; float mReflectionsFalloff; diff --git a/es-core/src/components/VideoComponent.cpp b/es-core/src/components/VideoComponent.cpp index b0ebf299f..3e0d46ab0 100644 --- a/es-core/src/components/VideoComponent.cpp +++ b/es-core/src/components/VideoComponent.cpp @@ -206,6 +206,32 @@ void VideoComponent::applyTheme(const std::shared_ptr& theme, } imageTypes = Utils::String::replace(imageTypes, ",,", ","); mThemeImageTypes = Utils::String::delimitedStringToVector(imageTypes, ","); + + if (mThemeImageTypes.empty()) { + LOG(LogError) << "VideoComponent: Invalid theme configuration, property " + "contains no values"; + } + + for (std::string& type : mThemeImageTypes) { + if (std::find(supportedImageTypes.cbegin(), supportedImageTypes.cend(), type) == + supportedImageTypes.cend()) { + LOG(LogError) + << "VideoComponent: Invalid theme configuration, property " + "defined as \"" + << type << "\""; + mThemeImageTypes.clear(); + break; + } + } + + std::vector sortedTypes {mThemeImageTypes}; + std::stable_sort(sortedTypes.begin(), sortedTypes.end()); + + if (std::adjacent_find(sortedTypes.begin(), sortedTypes.end()) != sortedTypes.end()) { + LOG(LogError) << "VideoComponent: Invalid theme configuration, property " + "contains duplicate values"; + mThemeImageTypes.clear(); + } } if (elem->has("pillarboxes")) diff --git a/es-core/src/components/VideoComponent.h b/es-core/src/components/VideoComponent.h index 5709fada3..96000837b 100644 --- a/es-core/src/components/VideoComponent.h +++ b/es-core/src/components/VideoComponent.h @@ -113,6 +113,10 @@ protected: std::string mStaticImagePath; std::string mDefaultImagePath; + static inline std::vector supportedImageTypes { + "image", "miximage", "marquee", "screenshot", "titlescreen", + "cover", "backcover", "3dbox", "physicalmedia", "fanart"}; + std::string mVideoPath; unsigned mStartTime; std::atomic mIsPlaying;