diff --git a/lib/Epub/Epub/css/CssParser.cpp b/lib/Epub/Epub/css/CssParser.cpp index 77ee8e77..64939fc8 100644 --- a/lib/Epub/Epub/css/CssParser.cpp +++ b/lib/Epub/Epub/css/CssParser.cpp @@ -431,6 +431,11 @@ CssStyle CssParser::parseDeclarations(std::string_view declBlock) { // Rule processing void CssParser::processRuleBlockWithStyle(std::string_view selectorGroup, const CssStyle& style) { + // Skip rules that don't define any supported properties to save RAM. + if (!style.defined.anySet()) { + return; + } + // Check if we've reached the rule limit before processing if (rulesBySelector_.size() >= MAX_RULES) { LOG_DBG("CSS", "Reached max rules limit (%zu), stopping CSS parsing", MAX_RULES); diff --git a/lib/Epub/Epub/css/CssParser.h b/lib/Epub/Epub/css/CssParser.h index 41797fd3..892216b3 100644 --- a/lib/Epub/Epub/css/CssParser.h +++ b/lib/Epub/Epub/css/CssParser.h @@ -33,7 +33,7 @@ class CssParser { public: // Bump when CSS cache format or rules change; section caches are invalidated when this changes - static constexpr uint8_t CSS_CACHE_VERSION = 7; + static constexpr uint8_t CSS_CACHE_VERSION = 8; explicit CssParser(std::string cachePath) : cachePath(std::move(cachePath)) {} ~CssParser() = default;