aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzard <fuzzard@users.noreply.github.com>2020-11-29 10:14:11 +1000
committerGitHub <noreply@github.com>2020-11-29 10:14:11 +1000
commit3c69cce6d42571033e4434e68b5e7fc841c6ec13 (patch)
treea93b3c88db603dd8db1fa5d6d33fa55d41e34de1
parent2dca05a1876409ac599678f91618e660543f221e (diff)
parent9d09af9aaff09394c4bcaabd4fd6690b4f0527cd (diff)
Merge pull request #18861 from simonaldrich/httpdirectory-item-links-with-colons
Detect HTTP Directory items which contain a colon
-rw-r--r--xbmc/filesystem/HTTPDirectory.cpp13
-rw-r--r--xbmc/filesystem/test/TestHTTPDirectory.cpp2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/apache-default.html2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/apache-fancy.html2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/apache-html.html2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/basic-multiline.html2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/basic.html2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/lighttp-default.html2
-rw-r--r--xbmc/filesystem/test/data/httpdirectory/nginx-default.html2
9 files changed, 20 insertions, 9 deletions
diff --git a/xbmc/filesystem/HTTPDirectory.cpp b/xbmc/filesystem/HTTPDirectory.cpp
index 851d9bc74a..e9323bd1e4 100644
--- a/xbmc/filesystem/HTTPDirectory.cpp
+++ b/xbmc/filesystem/HTTPDirectory.cpp
@@ -142,9 +142,20 @@ bool CHTTPDirectory::GetDirectory(const CURL& url, CFileItemList &items)
StringUtils::StartsWith(strLinkTemp, strNameTemp.substr(0, strNameTemp.length() - 3)))
strName = strNameTemp = strLinkTemp;
+ /* Per RFC 1808 ยง 5.3, relative paths containing a colon ":" should be either prefixed with
+ * "./" or escaped (as "%3A"). This handles the prefix case, the escaping should be handled by
+ * the CURL::Decode above
+ * - https://tools.ietf.org/html/rfc1808#section-5.3
+ */
+ auto NameMatchesLink([](const std::string& name, const std::string& link) -> bool
+ {
+ return (name == link) ||
+ ((std::string::npos != name.find(':')) && (std::string{"./"}.append(name) == link));
+ });
+
// we detect http directory items by its display name and its stripped link
// if same, we consider it as a valid item.
- if (strNameTemp == strLinkTemp && strLinkTemp != "..")
+ if (NameMatchesLink(strNameTemp, strLinkTemp) && strLinkTemp != "..")
{
CFileItemPtr pItem(new CFileItem(strNameTemp));
pItem->SetProperty("IsHTTPDirectory", true);
diff --git a/xbmc/filesystem/test/TestHTTPDirectory.cpp b/xbmc/filesystem/test/TestHTTPDirectory.cpp
index 3ca4784a71..1dd6e132ab 100644
--- a/xbmc/filesystem/test/TestHTTPDirectory.cpp
+++ b/xbmc/filesystem/test/TestHTTPDirectory.cpp
@@ -41,7 +41,7 @@ using namespace XFILE;
#define SAMPLE_ITEM_1_LABEL "folder1"
#define SAMPLE_ITEM_2_LABEL "folder2"
-#define SAMPLE_ITEM_3_LABEL "sample3.mpg"
+#define SAMPLE_ITEM_3_LABEL "sample3: the sampling.mpg"
#define SAMPLE_ITEM_4_LABEL "sample4.mpg"
#define SAMPLE_ITEM_5_LABEL "sample5.mpg"
#define SAMPLE_ITEM_6_LABEL "sample6.mpg"
diff --git a/xbmc/filesystem/test/data/httpdirectory/apache-default.html b/xbmc/filesystem/test/data/httpdirectory/apache-default.html
index 0aa8210c8f..a0644d7c98 100644
--- a/xbmc/filesystem/test/data/httpdirectory/apache-default.html
+++ b/xbmc/filesystem/test/data/httpdirectory/apache-default.html
@@ -7,7 +7,7 @@
<h1>Index of /</h1>
<ul><li><a href="folder1/"> folder1/</a></li>
<li><a href="folder2/"> folder2/</a></li>
-<li><a href="sample3.mpg"> sample3.mpg</a></li>
+<li><a href="./sample3:%20the%20sampling.mpg"> sample3: the sampling.mpg</a></li>
<li><a href="sample4.mpg"> sample4.mpg</a></li>
<li><a href="sample5.mpg"> sample5.mpg</a></li>
<li><a href="sample6.mpg"> sample6.mpg</a></li>
diff --git a/xbmc/filesystem/test/data/httpdirectory/apache-fancy.html b/xbmc/filesystem/test/data/httpdirectory/apache-fancy.html
index 92552166f3..8096aabbf8 100644
--- a/xbmc/filesystem/test/data/httpdirectory/apache-fancy.html
+++ b/xbmc/filesystem/test/data/httpdirectory/apache-fancy.html
@@ -7,7 +7,7 @@
<h1>Index of /</h1>
<pre> <a href="?C=N;O=D;F=1">Name</a> <a href="?C=M;O=A;F=1">Last modified</a> <a href="?C=S;O=A;F=1">Size</a> <a href="?C=D;O=A;F=1">Description</a><hr> <a href="folder1/">folder1/</a> 2019-01-01 01:01 -
<a href="folder2/">folder2/</a> 2019-02-02 02:02 -
- <a href="sample3.mpg">sample3.mpg</a> 2019-03-03 03:03 123
+ <a href="./sample3:%20the%20sampling.mpg">sample3: the sampling.mpg</a> 2019-03-03 03:03 123
<a href="sample4.mpg">sample4.mpg</a> 2019-04-04 04:04 123K
<a href="sample5.mpg">sample5.mpg</a> 2019-05-05 05:05 123M
<a href="sample6.mpg">sample6.mpg</a> 2019-06-06 06:06 123G
diff --git a/xbmc/filesystem/test/data/httpdirectory/apache-html.html b/xbmc/filesystem/test/data/httpdirectory/apache-html.html
index 676e6ba788..c57343f3d5 100644
--- a/xbmc/filesystem/test/data/httpdirectory/apache-html.html
+++ b/xbmc/filesystem/test/data/httpdirectory/apache-html.html
@@ -10,7 +10,7 @@
<tr><th colspan="5"><hr></th></tr>
<tr><td valign="top">&nbsp;</td><td><a href="folder1/">folder1/</a> </td><td align="right">2019-01-01 01:01 </td><td align="right"> - </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="folder2/">folder2/</a> </td><td align="right">2019-02-02 02:02 </td><td align="right"> - </td><td>&nbsp;</td></tr>
-<tr><td valign="top">&nbsp;</td><td><a href="sample3.mpg">sample3.mpg</a> </td><td align="right">2019-03-03 03:03 </td><td align="right">123 </td><td>&nbsp;</td></tr>
+<tr><td valign="top">&nbsp;</td><td><a href="./sample3:%20the%20sampling.mpg">sample3: the sampling.mpg</a> </td><td align="right">2019-03-03 03:03 </td><td align="right">123 </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="sample4.mpg">sample4.mpg</a> </td><td align="right">2019-04-04 04:04 </td><td align="right">123K</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="sample5.mpg">sample5.mpg</a> </td><td align="right">2019-05-05 05:05 </td><td align="right">123M</td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="sample6.mpg">sample6.mpg</a> </td><td align="right">2019-06-06 06:06 </td><td align="right">123G</td><td>&nbsp;</td></tr>
diff --git a/xbmc/filesystem/test/data/httpdirectory/basic-multiline.html b/xbmc/filesystem/test/data/httpdirectory/basic-multiline.html
index 8f23f546ab..c4ef5f77e0 100644
--- a/xbmc/filesystem/test/data/httpdirectory/basic-multiline.html
+++ b/xbmc/filesystem/test/data/httpdirectory/basic-multiline.html
@@ -7,7 +7,7 @@
<a href="folder2/">
folder2/
</a>
- <a href="sample3.mpg">sample3.mpg</a>
+ <a href="./sample3:%20the%20sampling.mpg">sample3: the sampling.mpg</a>
<a href="sample4.mpg">sample4.mpg</a> <a href="sample5.mpg">sample5.mpg</a>
<a href="sample6.mpg">
sample6.mpg
diff --git a/xbmc/filesystem/test/data/httpdirectory/basic.html b/xbmc/filesystem/test/data/httpdirectory/basic.html
index 09f207efad..43f2dc3bce 100644
--- a/xbmc/filesystem/test/data/httpdirectory/basic.html
+++ b/xbmc/filesystem/test/data/httpdirectory/basic.html
@@ -5,7 +5,7 @@
<body>
<a href="folder1/">folder1/</a>
<a href="folder2/">folder2/</a>
- <a href="sample3.mpg">sample3.mpg</a>
+ <a href="./sample3:%20the%20sampling.mpg">sample3: the sampling.mpg</a>
<a href="sample4.mpg">sample4.mpg</a>
<a href="sample5.mpg">sample5.mpg</a>
<a href="sample6.mpg">sample6.mpg</a>
diff --git a/xbmc/filesystem/test/data/httpdirectory/lighttp-default.html b/xbmc/filesystem/test/data/httpdirectory/lighttp-default.html
index 9aa7d3d383..5895ef863b 100644
--- a/xbmc/filesystem/test/data/httpdirectory/lighttp-default.html
+++ b/xbmc/filesystem/test/data/httpdirectory/lighttp-default.html
@@ -25,7 +25,7 @@ div.foot { font: 90% monospace; color: #787878; padding-top: 4px;}
<tbody>
<tr class="d"><td class="n"><a href="folder1/">folder1</a>/</td><td class="m">2019-Jan-01 01:01:01</td><td class="s">- &nbsp;</td><td class="t">Directory</td></tr>
<tr class="d"><td class="n"><a href="folder2/">folder2</a>/</td><td class="m">2019-Feb-02 02:02:02</td><td class="s">- &nbsp;</td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="sample3.mpg">sample3.mpg</a></td><td class="m">2019-Mar-03 03:03:03</td><td class="s">0.1K</td><td class="t">video/mpeg</td></tr>
+<tr><td class="n"><a href="sample3%3a%20the%20sampling.mpg">sample3: the sampling.mpg</a></td><td class="m">2019-Mar-03 03:03:03</td><td class="s">0.1K</td><td class="t">video/mpeg</td></tr>
<tr><td class="n"><a href="sample4.mpg">sample4.mpg</a></td><td class="m">2019-Apr-04 04:04:04</td><td class="s">123.0K</td><td class="t">video/mpeg</td></tr>
<tr><td class="n"><a href="sample5.mpg">sample5.mpg</a></td><td class="m">2019-May-05 05:05:05</td><td class="s">123.0M</td><td class="t">video/mpeg</td></tr>
<tr><td class="n"><a href="sample6.mpg">sample6.mpg</a></td><td class="m">2019-Jun-06 06:06:06</td><td class="s">123.0G</td><td class="t">video/mpeg</td></tr>
diff --git a/xbmc/filesystem/test/data/httpdirectory/nginx-default.html b/xbmc/filesystem/test/data/httpdirectory/nginx-default.html
index 5942ed3229..909736cd02 100644
--- a/xbmc/filesystem/test/data/httpdirectory/nginx-default.html
+++ b/xbmc/filesystem/test/data/httpdirectory/nginx-default.html
@@ -3,7 +3,7 @@
<body>
<h1>Index of /</h1><hr><pre><a href="folder1/">folder1/</a> 01-Jan-2019 01:01 -
<a href="folder2/">folder2/</a> 02-Feb-2019 02:02 -
-<a href="sample3.mpg">sample3.mpg</a> 03-Mar-2019 03:03 123
+<a href="sample3%3A%20the%20sampling.mpg">sample3: the sampling.mpg</a> 03-Mar-2019 03:03 123
<a href="sample4.mpg">sample4.mpg</a> 04-Apr-2019 04:04 125952
<a href="sample5.mpg">sample5.mpg</a> 05-May-2019 05:05 128974848
<a href="sample6.mpg">sample6.mpg</a> 06-Jun-2019 06:06 132070244352