Skip to content

Commit 30a01d1

Browse files
authored
Merge pull request #903 from phunkyfish/fix-xml-file-format-check-omega
Fix xml file format check - Omega
2 parents 287042d + a8a9779 commit 30a01d1

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

pvr.iptvsimple/addon.xml.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<addon
33
id="pvr.iptvsimple"
4-
version="21.9.1"
4+
version="21.9.2"
55
name="IPTV Simple Client"
66
provider-name="nightik and Ross Nicholson">
77
<requires>@ADDON_DEPENDS@

pvr.iptvsimple/changelog.txt

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v21.9.2
2+
- Fix XML file format check
3+
- Always treat special paths as local
4+
15
v21.9.1
26
- Fix release build
37

src/iptvsimple/Epg.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,21 @@ const XmltvFileFormat Epg::GetXMLTVFileFormat(const char* buffer)
226226
if (!buffer)
227227
return XmltvFileFormat::INVALID;
228228

229-
// xml should starts with '<?xml'
230-
if (buffer[0] != '\x3C' || buffer[1] != '\x3F' || buffer[2] != '\x78' ||
231-
buffer[3] != '\x6D' || buffer[4] != '\x6C')
229+
if ((buffer[0] != '\x3C' && buffer[std::strlen(buffer) - 1] != '\x3E') || // Start with < and ends with >
230+
(buffer[0] != '\x3C' && buffer[1] != '\x3F' && buffer[2] != '\x78' && // xml should starts with '<?xml'
231+
buffer[3] != '\x6D' && buffer[4] != '\x6C'))
232232
{
233-
// check for BOM
234-
if (buffer[0] != '\xEF' || buffer[1] != '\xBB' || buffer[2] != '\xBF')
235-
{
236-
// check for tar archive
237-
if (strcmp(buffer + 0x101, "ustar") || strcmp(buffer + 0x101, "GNUtar"))
238-
return XmltvFileFormat::TAR_ARCHIVE;
239-
else
240-
return XmltvFileFormat::INVALID;
241-
}
233+
return XmltvFileFormat::NORMAL;
234+
}
235+
236+
// check for BOM
237+
if (buffer[0] != '\xEF' || buffer[1] != '\xBB' || buffer[2] != '\xBF')
238+
{
239+
// check for tar archive
240+
if (strcmp(buffer + 0x101, "ustar") || strcmp(buffer + 0x101, "GNUtar"))
241+
return XmltvFileFormat::TAR_ARCHIVE;
242+
else
243+
return XmltvFileFormat::INVALID;
242244
}
243245

244246
return XmltvFileFormat::NORMAL;

src/iptvsimple/utilities/WebUtils.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ bool WebUtils::IsNfsUrl(const std::string& url)
121121
return StringUtils::StartsWith(url, NFS_PREFIX);
122122
}
123123

124+
bool WebUtils::IsSpecialUrl(const std::string& url)
125+
{
126+
return StringUtils::StartsWith(url, SPECIAL_PREFIX);
127+
}
128+
124129
std::string WebUtils::RedactUrl(const std::string& url)
125130
{
126131
std::string redactedUrl = url;
@@ -139,7 +144,7 @@ std::string WebUtils::RedactUrl(const std::string& url)
139144
bool WebUtils::Check(const std::string& strURL, int connectionTimeoutSecs, bool isLocalPath)
140145
{
141146
// For local paths we only need to check existence of the file
142-
if (isLocalPath && FileUtils::FileExists(strURL))
147+
if ((isLocalPath || IsSpecialUrl(strURL)) && FileUtils::FileExists(strURL))
143148
return true;
144149

145150
//Otherwise it's remote

src/iptvsimple/utilities/WebUtils.h

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace iptvsimple
1616
static const std::string HTTP_PREFIX = "http://";
1717
static const std::string HTTPS_PREFIX = "https://";
1818
static const std::string NFS_PREFIX = "nfs://";
19+
static const std::string SPECIAL_PREFIX = "special://";
1920
static const std::string UDP_MULTICAST_PREFIX = "udp://@";
2021
static const std::string RTP_MULTICAST_PREFIX = "rtp://@";
2122

@@ -28,6 +29,7 @@ namespace iptvsimple
2829
static std::string ReadFileContentsStartOnly(const std::string& url, int* httpCode);
2930
static bool IsHttpUrl(const std::string& url);
3031
static bool IsNfsUrl(const std::string& url);
32+
static bool IsSpecialUrl(const std::string& url);
3133
static std::string RedactUrl(const std::string& url);
3234
static bool Check(const std::string& url, int connectionTimeoutSecs, bool isLocalPath = false);
3335
};

0 commit comments

Comments
 (0)