Skip to content
This repository

Several fixes concerning URL handling #1064

Merged
merged 7 commits into from about 2 years ago

6 participants

arnova Joakim Plate jmarshallnz Sascha Montellese Eric Trent Nelson
arnova
Collaborator
arnova commented

This commit fixes the way we handle URL encoded paths in various locations. Eg. the Webdav filesystem didn't work properly for finding local thumbs and fanart for stacks. Ideally we should still switch to using URLs for the Fileitem's path in CFileItem but since that's a major change, these fixes should remedy most of the issues in the mean time. Any feedback is welcome (it's not that unlikely that I missed stuff) + I like a signoff by a senior.

xbmc/URL.cpp
... ... @@ -718,3 +721,17 @@ void CURL::Encode(CStdString& strURLData)
718 721 }
719 722 strURLData = strResult;
720 723 }
  724 +
  725 +bool CURL::UsesEncoding(const CStdString& strPath)
  726 +{
  727 + CStdString strPath2(strPath);
  728 +
  729 + if (URIUtils::IsStack(strPath))
  730 + strPath2 = XFILE::CStackDirectory::GetFirstStackedFile(strPath);
  731 +
  732 + CURL url(strPath2);
  733 +
  734 + // For now assume only (quasi) http internet streams use URL encoding
  735 + return url.GetTranslatedProtocol() == "http" ||
  736 + url.GetTranslatedProtocol() == "https";
  737 +}
10
Joakim Plate Collaborator
elupus added a note

Several more... smb for example.

Joakim Plate Collaborator
elupus added a note

Hmm. Never mind. we use non encoded paths in xbmc, and encode on request libsmbclient.

Joakim Plate Collaborator
elupus added a note

I want to rename this function at least. It should be named similar to:

bool URIUtils::ProtocolHasEncodedHostname(const CStdString& prot)

so a function like:

bool URIUtils::ProtocolHasEncodedFilename(const CStdString& prot)
arnova Collaborator
arnova added a note

Yeah, I already figured that out about smb ;-) The only other possible real protocol that can be url encoded is ftp/ftps/sftp afaik. Only problem there is: url encoding is not mandatory (again: afaik), so I left that out for now.

I think a function name like :ProtocolHasEncodedPath() would be better here since one should also be able to pass a path only (without an actual filename) to the function. Agreed?

arnova Collaborator
arnova added a note

@elupus: Did you also meant moving the function from the CURL class to URIUtils? This doesn't makes sense IMO since the Encode/Decode functions is what this going to be used with mainly, which live in CURL:: space

Joakim Plate Collaborator
elupus added a note
arnova Collaborator
arnova added a note

@elupus: To be clear: It should become "URIUtils::ProtocolHasEncodedPath() then, right?

Joakim Plate Collaborator
elupus added a note

Yea that seem like a good name

arnova Collaborator
arnova added a note

One major drawback of doing it that way is that we have to (re)move this code out of the function then:
..
CStdString strPath2(strPath);

if (URIUtils::IsStack(strPath))
strPath2 = XFILE::CStackDirectory::GetFirstStackedFile(strPath);

CURL url(strPath2);
...
Is that really what we want since it forces us to add the code for each call to it? Perhaps something like bool URIUtils::IsURLEncoded(const CStdString& strPath) is a better candidate?

Joakim Plate Collaborator
elupus added a note

IsURLEncoded is a really bad name since only parts of the url can be urlencoded like hostname/password/username/options.

The function should return if the protocol in question has an encoded path. Noth if some sub-protocol has it. Feel free to add some other helper function that handles the stack complication.

We should strive at not mixing things that apply to the protocol itself and things that apply to a combined url.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/FileItem.cpp
... ... @@ -2223,6 +2223,7 @@ void CFileItemList::StackFiles()
2223 2223 VECCREGEXP::iterator expr = stackRegExps.begin();
2224 2224
2225 2225 URIUtils::Split(item1->GetPath(), filePath, file1);
  2226 + CURL::Decode(file1);
2
Joakim Plate Collaborator
elupus added a note

Will break %20 names on local file systems

arnova Collaborator
arnova added a note

I will add an "if UsesEncoding(file1)" (and obviously also for the one for file2) here as well. There reason I did this is because the outcome would be same as with the removed ::Decode() below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/URL.cpp
... ... @@ -708,7 +708,10 @@ void CURL::Encode(CStdString& strURLData)
708 708 {
709 709 int kar = (unsigned char)strURLData[i];
710 710 //if (kar == ' ') strResult += '+';
711   - if (isalnum(kar)) strResult += kar;
  711 + if (isalnum(kar) || strchr("$-_.+!*'()," , kar) )
  712 + {
  713 + strResult += kar;
  714 + }
712 715 else
2
Joakim Plate Collaborator
elupus added a note

I suspect this can break things. But from what i can tell from specs it should be correct. Might be worth getting in.

arnova Collaborator
arnova added a note

Well, actually in it's current state it broke things as it incorrectly encoded URLs. In theory there are places where we could even url encode url options seperators like ; and & or the path seperator / (which I missed btw. in my change above: will fix that up too). Anyway: we need to do this right and take for granted that it could cause regressions, imo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/filesystem/StackDirectory.cpp
... ... @@ -103,6 +104,13 @@
103 104 CStdString File1 = URIUtils::GetFileName(files[0]->GetPath());
104 105 CStdString File2 = URIUtils::GetFileName(files[1]->GetPath());
105 106
  107 + // Check if source path uses URL encoding
  108 + if (CURL::UsesEncoding(strCommonDir))
  109 + {
  110 + CURL::Decode(File1);
  111 + CURL::Decode(File2);
  112 + }
  113 +
8
Joakim Plate Collaborator
elupus added a note

I'm pondering if GetFileName shouldn't take care of this... might bring major pain thou.

arnova Collaborator
arnova added a note

I think doing it in GetFileName() would be best yeah. The only problem I see with that is cases where we use the outcome later on to reconstruct an URL-encoded path. It's your call...

jmarshallnz Owner
jmarshallnz added a note

I presume you're referring to CURL::GetFileName() - this kinda makes sense if we know that it uses encoding for the filename internally. It seems to me that encapsulation should be in the CURL::GetFileName/CURL::SetFileName() stuff as much as possible.

arnova Collaborator
arnova added a note

That indeed does make sense yeah. Only thing we need to carefully look at is how we handle filenames in CURL::. Looking at its code it doesn't seem entirely straight forward, since we also use Get/SetFilename internally there. One thing we could do is add an extra bool option to CURL:Set/GetFilename to tell them to URL encode/decode or not?

EDIT: One thing that came to mind is: shouldn't we just handle the filename inside URL the same as hostname/username/password, meaning we keep it decoded internally. And encode as soon as we do a Get()? It still feel like this will almost certainly cause regressions, but I think it's worth the risk?

arnova Collaborator
arnova added a note

I went through our codebase looking for uses of url.GetFileName() and I'm pretty confident that having GetFilename() & SetFilename() URL decode/encode will break stuff, so I doubt it's a good idea to do this. It seems like that URL decoding/encoding should only be performed for things like stacking and creating Infolabels, like we do now.

Joakim Plate Collaborator
elupus added a note
arnova Collaborator
arnova added a note

So I think this PR is ready for merge, right?

Joakim Plate Collaborator
elupus added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Joakim Plate elupus commented on the diff
xbmc/utils/URIUtils.cpp
... ... @@ -653,15 +662,12 @@ bool URIUtils::IsFTP(const CStdString& strFile)
653 662 if (IsStack(strFile))
654 663 strFile2 = CStackDirectory::GetFirstStackedFile(strFile);
655 664
656   - CURL url(strFile2);
657   -
658   - return url.GetTranslatedProtocol() == "ftp" ||
659   - url.GetTranslatedProtocol() == "ftps";
  665 + return strFile2.Left(4).Equals("ftp:") ||
  666 + strFile2.Left(5).Equals("ftps:");
660 667 }
2
Joakim Plate Collaborator
elupus added a note

This changes behavior. It was a translated path before.

arnova Collaborator
arnova added a note

Yeah but it only ever translated from ftpx:// to ftp://, which, as you know, only ever existed on Xbox for mplayer. Currently TranslateProtocol() only does translation for http & https protocols (just check the function). So I'm sure it doesn't change behavior. It just made this function more in line (and clear) with the functions surrounding it. 100% sure this is correct, since I wrote those functions back then ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Joakim Plate elupus commented on the diff
xbmc/utils/URIUtils.cpp
((8 lines not shown))
679 685 return bStrictCheck;
680 686
681   - if (strProtocol2 == "http" || strProtocol2 == "https" ||
682   - strProtocol == "rtp" || strProtocol == "udp" ||
683   - strProtocol == "rtmp" || strProtocol == "rtsp")
  687 + if (strProtocol2 == "http" || strProtocol2 == "https" ||
  688 + strProtocol2 == "tcp" || strProtocol2 == "udp" ||
  689 + strProtocol2 == "rtp" || strProtocol2 == "sdp" ||
  690 + strProtocol2 == "mms" || strProtocol2 == "mmst" ||
  691 + strProtocol2 == "mmsh" || strProtocol2 == "rtsp" ||
  692 + strProtocol2 == "rtmp" || strProtocol2 == "rtmpt" ||
  693 + strProtocol2 == "rtmpe" || strProtocol2 == "rtmpte" ||
  694 + strProtocol2 == "rtmps")
3
Joakim Plate Collaborator
elupus added a note

This scares me a bit. IsInternetStream is used for a lot of things. It could potentially break stuff, but i suppose the ones you added is likely safe.

arnova Collaborator
arnova added a note

Yeah but it IS the correct list now. I think we'll just have to wait and see whether it causes any regressions. Note that as it was, it also caused eg. CFileItem to look for thumbs/fanart on eg. tcp:// (which obviously doesn't work since it's an ffmpeg protocol, not one of our vfs's). Agreed?

EDIT: Just went through all uses of IsInternetStream() (not THAT many actually ;-)), and I don't see any problems with them in combination with the above changes (most of them are to prevent us from hitting the VFS anyway for eg. ffmpeg protocols).

Joakim Plate Collaborator
elupus added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
xbmc/URL.cpp
... ... @@ -704,8 +692,11 @@ void CURL::Encode(CStdString& strURLData)
704 692 for (int i = 0; i < (int)strURLData.size(); ++i)
705 693 {
706 694 int kar = (unsigned char)strURLData[i];
707   - //if (kar == ' ') strResult += '+';
708   - if (isalnum(kar)) strResult += kar;
  695 + //if (kar == ' ') strResult += '+'; // obsolete
  696 + if (isalnum(kar) || strchr("-_.!()/" , kar) ) // Don't URL encode / to allow encoding full paths
1
Joakim Plate Collaborator
elupus added a note

bad bad bad.. will break rar/zip and others... We must be able to encode full paths and have the not break url parsing of the full url. What you had before was right.

You can never ever url encode a full path, unless what you want is to make it fit in a component of a url.

comp1://comp2:comp3@comp4:comp5/comp6/comp7/comp8?comp9#comp10 and so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
arnova arnova commented on the diff
xbmc/URL.cpp
@@ -704,8 +692,11 @@ void CURL::Encode(CStdString& strURLData)
704 692 for (int i = 0; i < (int)strURLData.size(); ++i)
705 693 {
706 694 int kar = (unsigned char)strURLData[i];
707   - //if (kar == ' ') strResult += '+';
708   - if (isalnum(kar)) strResult += kar;
  695 + //if (kar == ' ') strResult += '+'; // obsolete
  696 + if (isalnum(kar) || strchr("-_.!()" , kar) ) // Don't URL encode these according to RFC1738s
  697 + {
1
arnova Collaborator
arnova added a note

@elupus: I fixed the above, as you can see :-) Thanks for the heads-up, I didn't realise how we handle zip/rar paths etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
arnova arnova merged commit de1b74d into from
arnova arnova closed this
Joakim Plate
Collaborator
elupus commented

Please don't be so quick on the merge button :(. I wanted some other persons opinion on this, like @jmarshallnz

arnova
Collaborator
arnova commented

Well, you didn't really make that clear, right? ;-)

Joakim Plate
Collaborator
elupus commented
arnova
Collaborator
arnova commented

Again, then you should have mentioned that you wanted a more thorough review, either yourself and/or jmarshall (which already looked over the code before anyway). But it's rather confusion if I fix all the things you mentioned, and all you say is "Yup, agree", as that doesn't tell me much right?

This way it feels like I'm being bossed around instead of having constructive feedback... If you want me to revert the whole thing again, let me know.

Joakim Plate
Collaborator
elupus commented
arnova
Collaborator
arnova commented

Ok, agreed. This is at least clear story that helps to improve "things" :-)

Let's bury the hatchet then, and let us both try to prevent annoyances like this in the future.... But clear communication is the key here, IMO...

jmarshallnz
Owner

@althekiller found the following:

This appears to be wrong according to RFC1738 http://www.ietf.org/rfc/rfc1738.txt. The particular section states:

Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
reserved characters used for their reserved purposes may be used
unencoded within a URL.

On the other hand, characters that are not required to be encoded
(including alphanumerics) may be encoded within the scheme-specific
part of a URL, as long as they are not being used for a reserved
purpose.

This change does neither of these. Given we're URL encoding the entire thing, none of the characters will be reserved, and thus we can encode everything if we wish to. Either we extend the list of characters that we don't need to encode, or we remove them. No point having some half-way house.

@arnova what was the reason behind this?

@elupus any reason why we shouldn't revert it?

Collaborator

The RFC says that those characters, along with a few others that were left out can OPTIONALLY be left unencoded. This commit is causing olympia some grief WRT passing regexs around for scrapers. I'd suggest a revert here.

EDIT: This is ATK

Collaborator
Collaborator

The reason we do this is that it is in line with what most webservers (Apache, lighttpd) do. We mainly need to do this in cases where we URL Decode, do stuff and URL encode again. One example is when we eg. URL decode for matching stacking regex-es, and URL encode the result again. If we use the result for eg. finding fanart and thumbs, the encoded filename must have the same characters-encoded as the original URL else a match against our directory cache returns false. I see a few options to deal with this:
1) We leave it this we and fix it in the places where it causes problems (it's not quite clear to me yet, which cases these are);
2) We make our regex engine handle URLs properly;
3) We make special character exclusion/inclusion optional either by a list or by a bool;
4) We make the directory cache's exist() function handle URL encoded files "better" (I have a few ideas for this, but I haven't looked into the code yet).

Owner

Why do we have only a subset of the special character list given in the RFC? It makes no sense to me at all to decide to only have some of them. I wouldn't have as much problem if we actually used them all, or there was some decent rationale as to why we're including only the ones we do.

The reason it caused issues was the regexp in the scraper was assuming that . and - were URL encoded (as they were before this commit) and now they're not. This isn't really the point though - the point is the code before was correct according to the RFC, and is still correct (but doesn't really make sense as it is) according to the RFC.

this commit seems to make duplicate entries in my video database when I made it scan for Updates since it probably cant find the old file entry thuse adding the movie as a new one... anybody noticed this?

Collaborator

@arnova please take a look at http://trac.xbmc.org/ticket/13433. Your changes to also encode/decode "." in an URL break rar:// (and probably zip:// paths and maybe others as well) in XBMC when updating from Eden to Frodo.

arnova
Collaborator
arnova commented

You probably have to ask the webserver builders why they implemented it this way (partially), I couldn't find any specifics about it. I just tested it with both Apache & lighttp and together with the RFC, this turned out to be the list of characters that is excluded from encoding. I also found another RFC about URI encoding, RFC2396. Specifically have a look at section 2.3 ("Unreserved characters"). See http://www.ietf.org/rfc/rfc2396.txt.

IMO it makes sense to resemble the behavior of webservers as much as possible.

jmarshallnz
Owner

But again, the link you give has more characters than you handle currently. Perhaps the sources of Apache or lighttp are what should be consulted?

arnova
Collaborator
arnova commented

That seems like a good idea yes, I'll look into that. Note that I figured out our character list by simply performing trail-and-error -> just created some files with special characters and see whether the webserver URL encodes them before sending them to the client.

jmarshallnz
Owner

lighttpd seems to use everything in the RFC except ~. Amusingly, their source contains incorrect comments.

arnova
Collaborator
arnova commented

That's weird, according to my tests it does NOT encode: * but it does encode ~ and '
Do you have a link?

jmarshallnz
Owner

That would be right - it's encoding ~ and ' (I missed that in the RFC list)

jmarshallnz
Owner

Apache isn't quite so obvious, but seems to encode everything except ".-*_ "?

http://svn.apache.org/viewvc/httpd/httpd/trunk/server/gen_test_char.c?view=markup

arnova
Collaborator
arnova commented

Indeed, not that obvious ;-). An idea could be to detect which characters use encoding in an URL-encoded string, and use that later on when re-encoding. This list could optionally be stored inside the CURL-object, although it's only a single instance where we actually do this now (StackDirectory) so that may not be that useful.

EDIT: And of course we should honor the minimal list that Apache & lighttp share

Joakim Plate
Collaborator
elupus commented
Tobias Hieta tru referenced this pull request from a commit in RasPlex/plex-home-theatre
Tobias Hieta tru Make plasma users happy by moving the clock and label around a bit
Fixes #1064
86986ca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
7 xbmc/FileItem.cpp
@@ -2223,6 +2223,9 @@ void CFileItemList::StackFiles()
2223 2223 VECCREGEXP::iterator expr = stackRegExps.begin();
2224 2224
2225 2225 URIUtils::Split(item1->GetPath(), filePath, file1);
  2226 + if (URIUtils::ProtocolHasEncodedFilename(CURL(filePath).GetProtocol() ) )
  2227 + CURL::Decode(file1);
  2228 +
2226 2229 int j;
2227 2230 while (expr != stackRegExps.end())
2228 2231 {
@@ -2253,6 +2256,8 @@ void CFileItemList::StackFiles()
2253 2256
2254 2257 CStdString file2, filePath2;
2255 2258 URIUtils::Split(item2->GetPath(), filePath2, file2);
  2259 + if (URIUtils::ProtocolHasEncodedFilename(CURL(filePath2).GetProtocol() ) )
  2260 + CURL::Decode(file2);
2256 2261
2257 2262 if (expr->RegFind(file2, offset) != -1)
2258 2263 {
@@ -2340,7 +2345,7 @@ void CFileItemList::StackFiles()
2340 2345 // the label is converted from utf8, but the filename is not)
2341 2346 if (!g_guiSettings.GetBool("filelists.showextensions"))
2342 2347 URIUtils::RemoveExtension(stackName);
2343   - CURL::Decode(stackName);
  2348 +
2344 2349 item1->SetLabel(stackName);
2345 2350 item1->m_dwSize = size;
2346 2351 break;
38 xbmc/URL.cpp
@@ -433,19 +433,7 @@ const CStdString& CURL::GetProtocol() const
433 433
434 434 const CStdString CURL::GetTranslatedProtocol() const
435 435 {
436   - if (m_strProtocol == "shout"
437   - || m_strProtocol == "daap"
438   - || m_strProtocol == "dav"
439   - || m_strProtocol == "tuxbox"
440   - || m_strProtocol == "lastfm"
441   - || m_strProtocol == "mms"
442   - || m_strProtocol == "rss")
443   - return "http";
444   -
445   - if (m_strProtocol == "davs")
446   - return "https";
447   -
448   - return m_strProtocol;
  436 + return TranslateProtocol(m_strProtocol);
449 437 }
450 438
451 439 const CStdString& CURL::GetFileType() const
@@ -704,8 +692,11 @@ void CURL::Encode(CStdString& strURLData)
704 692 for (int i = 0; i < (int)strURLData.size(); ++i)
705 693 {
706 694 int kar = (unsigned char)strURLData[i];
707   - //if (kar == ' ') strResult += '+';
708   - if (isalnum(kar)) strResult += kar;
  695 + //if (kar == ' ') strResult += '+'; // obsolete
  696 + if (isalnum(kar) || strchr("-_.!()" , kar) ) // Don't URL encode these according to RFC1738s
  697 + {
  698 + strResult += kar;
  699 + }
709 700 else
710 701 {
711 702 CStdString strTmp;
@@ -715,3 +706,20 @@ void CURL::Encode(CStdString& strURLData)
715 706 }
716 707 strURLData = strResult;
717 708 }
  709 +
  710 +CStdString CURL::TranslateProtocol(const CStdString& prot)
  711 +{
  712 + if (prot == "shout"
  713 + || prot == "daap"
  714 + || prot == "dav"
  715 + || prot == "tuxbox"
  716 + || prot == "lastfm"
  717 + || prot == "rss")
  718 + return "http";
  719 +
  720 + if (prot == "davs")
  721 + return "https";
  722 +
  723 + return prot;
  724 +}
  725 +
2  xbmc/URL.h
@@ -71,6 +71,8 @@ class CURL
71 71 static bool IsFullPath(const CStdString &url); ///< return true if the url includes the full path
72 72 static void Decode(CStdString& strURLData);
73 73 static void Encode(CStdString& strURLData);
  74 + static CStdString TranslateProtocol(const CStdString& prot);
  75 +
74 76 protected:
75 77 int m_iPort;
76 78 CStdString m_strHostName;
15 xbmc/filesystem/StackDirectory.cpp
@@ -25,6 +25,7 @@
25 25 #include "FileItem.h"
26 26 #include "utils/StringUtils.h"
27 27 #include "settings/AdvancedSettings.h"
  28 +#include "URL.h"
28 29
29 30 using namespace std;
30 31 namespace XFILE
@@ -102,6 +103,12 @@ namespace XFILE
102 103
103 104 CStdString File1 = URIUtils::GetFileName(files[0]->GetPath());
104 105 CStdString File2 = URIUtils::GetFileName(files[1]->GetPath());
  106 + // Check if source path uses URL encoding
  107 + if (URIUtils::ProtocolHasEncodedFilename(CURL(strCommonDir).GetProtocol()))
  108 + {
  109 + CURL::Decode(File1);
  110 + CURL::Decode(File2);
  111 + }
105 112
106 113 std::vector<CRegExp>::iterator itRegExp = RegExps.begin();
107 114 int offset = 0;
@@ -131,7 +138,13 @@ namespace XFILE
131 138 if (Ignore1.Equals(Ignore2) && Extension1.Equals(Extension2))
132 139 {
133 140 // got it
134   - strStackTitle = Title1 + Ignore1 + Extension1;
  141 + strStackTitle = Title1 + Ignore1;
  142 + // Check if source path uses URL encoding
  143 + if (URIUtils::ProtocolHasEncodedFilename(CURL(strCommonDir).GetProtocol()))
  144 + CURL::Encode(strStackTitle);
  145 +
  146 + strStackTitle += Extension1;
  147 +
135 148 itRegExp = RegExps.end();
136 149 break;
137 150 }
5 xbmc/utils/FileOperationJob.cpp
@@ -134,6 +134,11 @@ bool CFileOperationJob::DoProcess(FileAction action, CFileItemList & items, cons
134 134 URIUtils::RemoveSlashAtEnd(strNoSlash);
135 135 CStdString strFileName = URIUtils::GetFileName(strNoSlash);
136 136
  137 + // URL Decode for cases where source uses URL encoding and target does not
  138 + if ( URIUtils::ProtocolHasEncodedFilename(CURL(pItem->GetPath()).GetProtocol() )
  139 + && !URIUtils::ProtocolHasEncodedFilename(CURL(strDestFile).GetProtocol() ) )
  140 + CURL::Decode(strFileName);
  141 +
137 142 // special case for upnp
138 143 if (URIUtils::IsUPnP(items.GetPath()) || URIUtils::IsUPnP(pItem->GetPath()))
139 144 {
31 xbmc/utils/URIUtils.cpp
@@ -241,6 +241,15 @@ bool URIUtils::ProtocolHasEncodedHostname(const CStdString& prot)
241 241 || prot.Equals("musicsearch");
242 242 }
243 243
  244 +bool URIUtils::ProtocolHasEncodedFilename(const CStdString& prot)
  245 +{
  246 + CStdString prot2 = CURL::TranslateProtocol(prot);
  247 +
  248 + // For now assume only (quasi) http internet streams use URL encoding
  249 + return prot2 == "http" ||
  250 + prot2 == "https";
  251 +}
  252 +
244 253 CStdString URIUtils::GetParentPath(const CStdString& strPath)
245 254 {
246 255 CStdString strReturn;
@@ -653,15 +662,12 @@ bool URIUtils::IsFTP(const CStdString& strFile)
653 662 if (IsStack(strFile))
654 663 strFile2 = CStackDirectory::GetFirstStackedFile(strFile);
655 664
656   - CURL url(strFile2);
657   -
658   - return url.GetTranslatedProtocol() == "ftp" ||
659   - url.GetTranslatedProtocol() == "ftps";
  665 + return strFile2.Left(4).Equals("ftp:") ||
  666 + strFile2.Left(5).Equals("ftps:");
660 667 }
661 668
662 669 bool URIUtils::IsInternetStream(const CURL& url, bool bStrictCheck /* = false */)
663 670 {
664   -
665 671 CStdString strProtocol = url.GetProtocol();
666 672
667 673 if (strProtocol.IsEmpty())
@@ -674,13 +680,18 @@ bool URIUtils::IsInternetStream(const CURL& url, bool bStrictCheck /* = false */
674 680 CStdString strProtocol2 = url.GetTranslatedProtocol();
675 681
676 682 // Special case these
677   - if (strProtocol2 == "ftp" || strProtocol2 == "ftps" ||
678   - strProtocol == "dav" || strProtocol == "davs")
  683 + if (strProtocol == "ftp" || strProtocol == "ftps" ||
  684 + strProtocol == "dav" || strProtocol == "davs")
679 685 return bStrictCheck;
680 686
681   - if (strProtocol2 == "http" || strProtocol2 == "https" ||
682   - strProtocol == "rtp" || strProtocol == "udp" ||
683   - strProtocol == "rtmp" || strProtocol == "rtsp")
  687 + if (strProtocol2 == "http" || strProtocol2 == "https" ||
  688 + strProtocol2 == "tcp" || strProtocol2 == "udp" ||
  689 + strProtocol2 == "rtp" || strProtocol2 == "sdp" ||
  690 + strProtocol2 == "mms" || strProtocol2 == "mmst" ||
  691 + strProtocol2 == "mmsh" || strProtocol2 == "rtsp" ||
  692 + strProtocol2 == "rtmp" || strProtocol2 == "rtmpt" ||
  693 + strProtocol2 == "rtmpe" || strProtocol2 == "rtmpte" ||
  694 + strProtocol2 == "rtmps")
684 695 return true;
685 696
686 697 return false;
1  xbmc/utils/URIUtils.h
@@ -112,5 +112,6 @@ class URIUtils
112 112
113 113 static bool ProtocolHasParentInHostname(const CStdString& prot);
114 114 static bool ProtocolHasEncodedHostname(const CStdString& prot);
  115 + static bool ProtocolHasEncodedFilename(const CStdString& prot);
115 116 };
116 117

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.