From d22dffd4a9da5527d9d8dad2874e9f6286b4a668 Mon Sep 17 00:00:00 2001 From: ulion Date: Sat, 2 Mar 2013 05:28:57 +0800 Subject: Switch ftp to use protocol options, rather than url options. --- xbmc/URL.cpp | 2 +- xbmc/filesystem/CurlFile.cpp | 63 ++++++++++++++------------------------------ 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/xbmc/URL.cpp b/xbmc/URL.cpp index c629995b95..f0d81b4ebe 100644 --- a/xbmc/URL.cpp +++ b/xbmc/URL.cpp @@ -195,7 +195,7 @@ void CURL::Parse(const CStdString& strURL1) sep = "?;#|"; else if(strProtocol2.Equals("ftp") || strProtocol2.Equals("ftps")) - sep = "?;"; + sep = "?;|"; if(sep) { diff --git a/xbmc/filesystem/CurlFile.cpp b/xbmc/filesystem/CurlFile.cpp index 2c5da25a10..7cddb638cf 100644 --- a/xbmc/filesystem/CurlFile.cpp +++ b/xbmc/filesystem/CurlFile.cpp @@ -647,6 +647,15 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2) if( strProtocol.Equals("ftp") || strProtocol.Equals("ftps") ) { + // we was using url optons for urls, keep the old code work and warning + if (!url2.GetOptions().IsEmpty()) + { + CLog::Log(LOGWARNING, "%s: ftp url option is deprecated, please switch to use protocol option (change '?' to '|'), url: [%s]", __FUNCTION__, url2.Get().c_str()); + url2.SetProtocolOptions(url2.GetOptions().Mid(1)); + /* ftp has no options */ + url2.SetOptions(""); + } + /* this is uggly, depending on from where */ /* we get the link it may or may not be */ /* url encoded. if handed from ftpdirectory */ @@ -677,53 +686,21 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2) url2.SetFileName(filename); - CStdString options = url2.GetOptions().Mid(1); - options.TrimRight('/'); // hack for trailing slashes being added from source - m_ftpauth = ""; + if (url2.HasProtocolOption("auth")) + { + m_ftpauth = url2.GetProtocolOption("auth"); + if(m_ftpauth.IsEmpty()) + m_ftpauth = "any"; + } m_ftpport = ""; - m_ftppasvip = false; - - /* parse options given */ - CUtil::Tokenize(options, array, "&"); - for(CStdStringArray::iterator it = array.begin(); it != array.end(); it++) + if (url2.HasProtocolOption("active")) { - CStdString name, value; - int pos = it->Find('='); - if(pos >= 0) - { - name = it->Left(pos); - value = it->Mid(pos+1, it->size()); - } - else - { - name = (*it); - value = ""; - } - - if(name.Equals("auth")) - { - m_ftpauth = value; - if(m_ftpauth.IsEmpty()) - m_ftpauth = "any"; - } - else if(name.Equals("active")) - { - m_ftpport = value; - if(value.IsEmpty()) - m_ftpport = "-"; - } - else if(name.Equals("pasvip")) - { - if(value == "0") - m_ftppasvip = false; - else - m_ftppasvip = true; - } + m_ftpport = url2.GetProtocolOption("active"); + if(m_ftpport.IsEmpty()) + m_ftpport = "-"; } - - /* ftp has no options */ - url2.SetOptions(""); + m_ftppasvip = url2.HasProtocolOption("pasvip") && url2.GetProtocolOption("pasvip") != "0"; } else if( strProtocol.Equals("http") || strProtocol.Equals("https")) -- cgit v1.2.3