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 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 '