From c782021bebd99649ca0161e9473fe9d7ee6b2146 Mon Sep 17 00:00:00 2001 From: phunkyfish Date: Tue, 29 Oct 2024 09:59:35 +0000 Subject: [PATCH 1/2] Take account of whitespace at end of xmltv file while doing format check --- src/iptvsimple/Epg.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/iptvsimple/Epg.cpp b/src/iptvsimple/Epg.cpp index 4af778e9..66efbca5 100644 --- a/src/iptvsimple/Epg.cpp +++ b/src/iptvsimple/Epg.cpp @@ -221,12 +221,35 @@ char* Epg::FillBufferFromXMLTVData(std::string& data, std::string& decompressedD return buffer; } +namespace { + +char GetLastValidCharInBuffer(const char* buffer) +{ + size_t charIndex = std::strlen(buffer) - 1; + char lastValidChar = buffer[charIndex]; + + while (charIndex != 0 && + (buffer[charIndex] == ' ' || + buffer[charIndex] == '\t'|| + buffer[charIndex] == '\n' || + buffer[charIndex] == '\r' || + buffer[charIndex] == '\f' || + buffer[charIndex] == '\v')) + { + lastValidChar = buffer[--charIndex]; + } + + return lastValidChar; +} + +} // unnamed namespace + const XmltvFileFormat Epg::GetXMLTVFileFormat(const char* buffer) { if (!buffer) return XmltvFileFormat::INVALID; - if ((buffer[0] == '\x3C' && buffer[std::strlen(buffer) - 1] == '\x3E') || // Start with < and ends with > + if ((buffer[0] == '\x3C' && GetLastValidCharInBuffer(buffer) == '\x3E') || // Start with < and ends with > (buffer[0] == '\x3C' && buffer[1] == '\x3F' && buffer[2] == '\x78' && // xml should starts with ' Date: Tue, 29 Oct 2024 10:00:24 +0000 Subject: [PATCH 2/2] changelog and version 22.3.1 --- pvr.iptvsimple/addon.xml.in | 2 +- pvr.iptvsimple/changelog.txt | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pvr.iptvsimple/addon.xml.in b/pvr.iptvsimple/addon.xml.in index 214f9348..7bfd3d93 100644 --- a/pvr.iptvsimple/addon.xml.in +++ b/pvr.iptvsimple/addon.xml.in @@ -1,7 +1,7 @@ @ADDON_DEPENDS@ diff --git a/pvr.iptvsimple/changelog.txt b/pvr.iptvsimple/changelog.txt index fcd19a45..21f10e05 100644 --- a/pvr.iptvsimple/changelog.txt +++ b/pvr.iptvsimple/changelog.txt @@ -1,3 +1,6 @@ +v22.3.1 +- Take account of whitespace at end of xmltv file while doing format check + v22.3.0 - PVR Add-on API v9.2.0