From 8806d6ab08ecc16aa27e3bbca70fc0641e702d10 Mon Sep 17 00:00:00 2001 From: CastagnaIT Date: Tue, 3 Sep 2024 08:37:58 +0200 Subject: [PATCH] [PlaylistLoader] Fix KODIPROP parsing kodi props must be read in full without use delimiters that break the string at first space or double accents " otherwise lead to broken properties values --- src/iptvsimple/PlaylistLoader.cpp | 38 +++++++++++++++++++------------ src/iptvsimple/PlaylistLoader.h | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/iptvsimple/PlaylistLoader.cpp b/src/iptvsimple/PlaylistLoader.cpp index d05abf8f4..eca0343cc 100644 --- a/src/iptvsimple/PlaylistLoader.cpp +++ b/src/iptvsimple/PlaylistLoader.cpp @@ -552,7 +552,7 @@ void PlaylistLoader::ParseAndAddChannelGroups(const std::string& groupNamesListS void PlaylistLoader::ParseSinglePropertyIntoChannel(const std::string& line, Channel& channel, const std::string& markerName) { - const std::string value = ReadMarkerValue(line, markerName); + const std::string value = ReadMarkerValue(line, markerName, markerName != KODIPROP_MARKER); auto pos = value.find('='); if (pos != std::string::npos) { @@ -604,7 +604,9 @@ void PlaylistLoader::ReloadPlayList() } } -std::string PlaylistLoader::ReadMarkerValue(const std::string& line, const std::string& markerName) +std::string PlaylistLoader::ReadMarkerValue(const std::string& line, + const std::string& markerName, + bool isCheckDelimiters /* = true */) { size_t markerStart = line.find(markerName); if (markerStart != std::string::npos) @@ -613,21 +615,29 @@ std::string PlaylistLoader::ReadMarkerValue(const std::string& line, const std:: markerStart += marker.length(); if (markerStart < line.length()) { - if (marker == M3U_GROUP_MARKER && line[markerStart] != '"') + size_t markerEnd; + if (isCheckDelimiters) { - //For this case we just want to return the full string without splitting it - //This is because groups use semi-colons and not spaces as a delimiter - return line.substr(markerStart, line.length()); - } + if (marker == M3U_GROUP_MARKER && line[markerStart] != '"') + { + //For this case we just want to return the full string without splitting it + //This is because groups use semi-colons and not spaces as a delimiter + return line.substr(markerStart, line.length()); + } - char find = ' '; - if (line[markerStart] == '"') - { - find = '"'; - markerStart++; + char find = ' '; + if (line[markerStart] == '"') + { + find = '"'; + markerStart++; + } + markerEnd = line.find(find, markerStart); + if (markerEnd == std::string::npos) + { + markerEnd = line.length(); + } } - size_t markerEnd = line.find(find, markerStart); - if (markerEnd == std::string::npos) + else { markerEnd = line.length(); } diff --git a/src/iptvsimple/PlaylistLoader.h b/src/iptvsimple/PlaylistLoader.h index b2cdaa6cb..6366a50d1 100644 --- a/src/iptvsimple/PlaylistLoader.h +++ b/src/iptvsimple/PlaylistLoader.h @@ -75,7 +75,7 @@ namespace iptvsimple void ReloadPlayList(); private: - static std::string ReadMarkerValue(const std::string& line, const std::string& markerName); + static std::string ReadMarkerValue(const std::string& line, const std::string& markerName, bool isCheckDelimiters = true); static void ParseSinglePropertyIntoChannel(const std::string& line, iptvsimple::data::Channel& channel, const std::string& markerName); std::string ParseIntoChannel(const std::string& line, iptvsimple::data::Channel& channel, data::MediaEntry& mediaEntry, int epgTimeShift, int catchupCorrectionSecs, bool xeevCatchup);