CURL: remove Encode() overload; Encode() return new value instead of modifying parameter,
authorKarlson2k <k2k@narod.ru>
Tue, 14 Jan 2014 02:10:39 +0000 (06:10 +0400)
committerKarlson2k <k2k@narod.ru>
Wed, 15 Jan 2014 05:57:05 +0000 (09:57 +0400)
include fix of using wrong Encode() overload introduced in  5dc310eb2dd6bee1207cd29b1ce4a7eb5cf57fff

21 files changed:
xbmc/URL.cpp
xbmc/URL.h
xbmc/addons/GUIDialogAddonSettings.cpp
xbmc/addons/Scraper.cpp
xbmc/filesystem/AFPFile.cpp
xbmc/filesystem/CurlFile.cpp
xbmc/filesystem/MultiPathDirectory.cpp
xbmc/filesystem/SAPDirectory.cpp
xbmc/filesystem/SMBDirectory.cpp
xbmc/filesystem/SmbFile.cpp
xbmc/filesystem/StackDirectory.cpp
xbmc/filesystem/UPnPDirectory.cpp
xbmc/filesystem/ZeroconfDirectory.cpp
xbmc/music/windows/GUIWindowMusicNav.cpp
xbmc/network/AirPlayServer.cpp
xbmc/network/WebServer.cpp
xbmc/network/upnp/UPnP.cpp
xbmc/network/upnp/UPnPServer.cpp
xbmc/utils/ScraperParser.cpp
xbmc/utils/ScraperUrl.cpp
xbmc/utils/URIUtils.cpp

index 07154fb..d7bb470 100644 (file)
@@ -40,7 +40,7 @@ using namespace ADDON;
 CStdString URLEncodeInline(const CStdString& strData)
 {
   CStdString buffer = strData;
-  CURL::Encode(buffer);
+  buffer = CURL::Encode(buffer);
   return buffer;
 }
 
@@ -128,7 +128,7 @@ void CURL::Parse(const CStdString& strURL1)
         if (!(s.st_mode & S_IFDIR))
 #endif
         {
-          Encode(archiveName);
+          archiveName = Encode(archiveName);
           if (is_apk)
           {
             CURL c("apk://" + archiveName + "/" + strURL.substr(iPos + 1));
@@ -743,9 +743,9 @@ void CURL::Decode(CStdString& strURLData)
   strURLData = strResult;
 }
 
-void CURL::Encode(CStdString& strURLData)
+std::string CURL::Encode(const std::string& strURLData)
 {
-  CStdString strResult;
+  std::string strResult;
 
   /* wonder what a good value is here is, depends on how often it occurs */
   strResult.reserve( strURLData.length() * 2 );
@@ -764,7 +764,8 @@ void CURL::Encode(CStdString& strURLData)
       strResult += strTmp;
     }
   }
-  strURLData = strResult;
+
+  return strResult;
 }
 
 std::string CURL::Decode(const std::string& strURLData)
@@ -774,13 +775,6 @@ std::string CURL::Decode(const std::string& strURLData)
   return url;
 }
 
-std::string CURL::Encode(const std::string& strURLData)
-{
-  CStdString url = strURLData;
-  Encode(url);
-  return url;
-}
-
 CStdString CURL::TranslateProtocol(const CStdString& prot)
 {
   if (prot == "shout"
index 1b510b1..2a2fc20 100644 (file)
@@ -72,7 +72,6 @@ public:
   static bool IsFileOnly(const CStdString &url); ///< return true if there are no directories in the url.
   static bool IsFullPath(const CStdString &url); ///< return true if the url includes the full path
   static void Decode(CStdString& strURLData);
-  static void Encode(CStdString& strURLData);
   static std::string Decode(const std::string& strURLData);
   static std::string Encode(const std::string& strURLData);
   static CStdString TranslateProtocol(const CStdString& prot);
index 975b1af..8406ee0 100644 (file)
@@ -265,7 +265,7 @@ bool CGUIDialogAddonSettings::ShowVirtualKeyboard(int iControl)
             else
               ((CGUIButtonControl*) control)->SetLabel2(value);
             if (bEncoded)
-              CURL::Encode(value);
+              value = CURL::Encode(value);
           }
         }
         else if (strcmp(type, "number") == 0 && CGUIDialogNumeric::ShowAndGetNumber(value, label))
index b4684bc..42a3757 100644 (file)
@@ -576,7 +576,7 @@ std::vector<CScraperUrl> CScraper::FindMovie(XFILE::CCurlFile &fcurl, const CStd
 
   vector<CStdString> vcsIn(1);
   g_charsetConverter.utf8To(SearchStringEncoding(), sTitle, vcsIn[0]);
-  CURL::Encode(vcsIn[0]);
+  vcsIn[0] = CURL::Encode(vcsIn[0]);
   if (!sYear.empty())
     vcsIn.push_back(sYear);
 
@@ -702,8 +702,8 @@ std::vector<CMusicAlbumInfo> CScraper::FindAlbum(CCurlFile &fcurl, const CStdStr
   std::vector<CStdString> extras(2);
   g_charsetConverter.utf8To(SearchStringEncoding(), sAlbum, extras[0]);
   g_charsetConverter.utf8To(SearchStringEncoding(), sArtist, extras[1]);
-  CURL::Encode(extras[0]);
-  CURL::Encode(extras[1]);
+  extras[0] = CURL::Encode(extras[0]);
+  extras[1] = CURL::Encode(extras[1]);
   CScraperUrl scurl;
   vector<CStdString> vcsOut = RunNoThrow("CreateAlbumSearchUrl", scurl, fcurl, &extras);
   if (vcsOut.size() > 1)
@@ -798,7 +798,7 @@ std::vector<CMusicArtistInfo> CScraper::FindArtist(CCurlFile &fcurl,
   // returns an XML <url> element parseable by CScraperUrl
   std::vector<CStdString> extras(1);
   g_charsetConverter.utf8To(SearchStringEncoding(), sArtist, extras[0]);
-  CURL::Encode(extras[0]);
+  extras[0] = CURL::Encode(extras[0]);
   CScraperUrl scurl;
   vector<CStdString> vcsOut = RunNoThrow("CreateArtistSearchUrl", scurl, fcurl, &extras);
 
@@ -1009,7 +1009,7 @@ bool CScraper::GetArtistDetails(CCurlFile &fcurl, const CScraperUrl &scurl,
   // pass in the original search string for chaining to search other sites
   vector<CStdString> vcIn;
   vcIn.push_back(sSearch);
-  CURL::Encode(vcIn[0]);
+  vcIn[0] = CURL::Encode(vcIn[0]);
 
   vector<CStdString> vcsOut = RunNoThrow("GetArtistDetails", scurl, fcurl, &vcIn);
 
index 8b24831..e731562 100644 (file)
@@ -41,7 +41,7 @@ using namespace XFILE;
 CStdString URLEncode(const CStdString value)
 {
   CStdString encoded(value);
-  CURL::Encode(encoded);
+  encoded = CURL::Encode(encoded);
   return encoded;
 }
 
index aee94c4..6d1b25a 100644 (file)
@@ -690,7 +690,7 @@ void CCurlFile::ParseAndCorrectUrl(CURL &url2)
         filename += "/";
 
       partial = *it;
-      CURL::Encode(partial);
+      partial = CURL::Encode(partial);
       filename += partial;
     }
 
index d273c4c..ff70d48 100644 (file)
@@ -225,7 +225,7 @@ void CMultiPathDirectory::AddToMultiPath(CStdString& strMultiPath, const CStdStr
   CStdString strPath1 = strPath;
   URIUtils::AddSlashAtEnd(strMultiPath);
   //CLog::Log(LOGDEBUG, "-- adding path: %s", strPath.c_str());
-  CURL::Encode(strPath1);
+  strPath1 = CURL::Encode(strPath1);
   strMultiPath += strPath1;
   strMultiPath += "/";
 }
index 4069fba..0f84e24 100644 (file)
@@ -365,7 +365,7 @@ bool CSAPSessions::ParseAnnounce(char* data, int len)
 
   // add a new session to our buffer
   CStdString user = origin.username;
-  CURL::Encode(user);
+  user = CURL::Encode(user);
   CStdString path = StringUtils::Format("sap://%s/%s/0x%x.sdp", header.origin.c_str(), desc.origin.c_str(), header.msgid);
   CSession session;
   session.path           = path;
index a9d6339..22d624a 100644 (file)
@@ -417,7 +417,7 @@ void CSMBDirectory::UnMountShare(const CStdString &strType, const CStdString &st
 CStdString CSMBDirectory::GetMountPoint(const CStdString &strType, const CStdString &strName)
 {
   CStdString strPath = strType + strName;
-  CURL::Encode(strPath);
+  strPath = CURL::Encode(strPath);
 
 #if defined(TARGET_DARWIN)
   CStdString str = getenv("HOME");
index 77dec38..34e0991 100644 (file)
@@ -245,7 +245,7 @@ CStdString CSMB::URLEncode(const CURL &url)
 CStdString CSMB::URLEncode(const CStdString &value)
 {
   CStdString encoded(value);
-  CURL::Encode(encoded);
+  encoded = CURL::Encode(encoded);
   return encoded;
 }
 
index 3d1bbac..9d1949a 100644 (file)
@@ -128,7 +128,7 @@ namespace XFILE
                   strStackTitle = Title1 + Ignore1 + Extension1;
                   // Check if source path uses URL encoding
                   if (URIUtils::ProtocolHasEncodedFilename(CURL(strCommonDir).GetProtocol()))
-                    CURL::Encode(strStackTitle);
+                    strStackTitle = CURL::Encode(strStackTitle);
 
                   itRegExp = RegExps.end();
                   break;
index 7be5af2..174a04c 100644 (file)
@@ -333,7 +333,7 @@ CUPnPDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
             else
                 id = (const char*) (*entry)->m_ReferenceID;
 
-            CURL::Encode(id);
+            id = CURL::Encode(id);
             URIUtils::AddSlashAtEnd(id);
             pItem->SetPath(CStdString((const char*) "upnp://" + uuid + "/" + id.c_str()));
 
index aaa61ca..4157e81 100644 (file)
@@ -187,7 +187,7 @@ bool CZeroconfDirectory::GetDirectory(const CStdString& strPath, CFileItemList &
         CURL url;
         url.SetProtocol("zeroconf");
         CStdString service_path = CZeroconfBrowser::ZeroconfService::toPath(*it);
-        CURL::Encode(service_path);
+        service_path = CURL::Encode(service_path);
         url.SetFileName(service_path);
         item->SetPath(url.Get());
 
index 09504c8..522e85c 100644 (file)
@@ -767,7 +767,7 @@ void CGUIWindowMusicNav::DisplayEmptyDatabaseMessage(bool bDisplay)
 void CGUIWindowMusicNav::OnSearchUpdate()
 {
   CStdString search(GetProperty("search").asString());
-  CURL::Encode(search);
+  search = CURL::Encode(search);
   if (!search.empty())
   {
     CStdString path = "musicsearch://" + search + "/";
index d6979c4..1e73405 100644 (file)
@@ -863,7 +863,7 @@ int CAirPlayServer::CTCPClient::ProcessRequest( CStdString& responseHeader,
     if (status != AIRPLAY_STATUS_NEED_AUTH)
     {
       CStdString userAgent="AppleCoreMedia/1.0.0.8F455 (AppleTV; U; CPU OS 4_3 like Mac OS X; de_de)";
-      CURL::Encode(userAgent);
+      userAgent = CURL::Encode(userAgent);
       location += "|User-Agent=" + userAgent;
 
       CFileItem fileToPlay(location, false);
index 96cb3cb..604066a 100644 (file)
@@ -853,7 +853,7 @@ bool CWebServer::PrepareDownload(const char *path, CVariant &details, std::strin
       url = "image/";
     else
       url = "vfs/";
-    CURL::Encode(strPath);
+    strPath = CURL::Encode(strPath);
     url += strPath;
     details["path"] = url;
     return true;
index 46692c2..7745c6d 100644 (file)
@@ -184,7 +184,7 @@ public:
         NPT_String path = "upnp://"+device->GetUUID()+"/";
         if (!NPT_StringsEqual(item_id, "0")) {
             CStdString id = item_id;
-            CURL::Encode(id);
+            id = CURL::Encode(id);
             URIUtils::AddSlashAtEnd(id);
             path += id.c_str();
         }
index 67f268d..368c8bb 100644 (file)
@@ -225,7 +225,7 @@ NPT_String CUPnPServer::BuildSafeResourceUri(const NPT_HttpUrl &rooturi,
     else
       filename = URIUtils::GetFileName(file_path);
 
-    CURL::Encode(filename);
+    filename = CURL::Encode(filename);
     md5state.append(file_path);
     md5state.getDigest(md5);
     md5 += "/" + filename;
index 6ad2887..c4f2ae2 100644 (file)
@@ -529,7 +529,7 @@ void CScraperParser::Clean(CStdString& strDirty)
     if ((i2 = strDirty.find("!!!ENCODE!!!",i+12)) != std::string::npos)
     {
       strBuffer = strDirty.substr(i+12,i2-i-12);
-      CURL::Encode(strBuffer);
+      strBuffer = CURL::Encode(strBuffer);
       strDirty.replace(i, i2-i+12, strBuffer);
       i += strBuffer.size();
     }
index 49919a1..1f9cff7 100644 (file)
@@ -347,7 +347,7 @@ CStdString CScraperUrl::GetThumbURL(const CScraperUrl::SUrlEntry &entry)
   if (entry.m_spoof.empty())
     return entry.m_url;
   CStdString spoof = entry.m_spoof;
-  CURL::Encode(spoof);
+  spoof = CURL::Encode(spoof);
   return entry.m_url + "|Referer=" + spoof;
 }
 
index 1f44d6f..68be135 100644 (file)
@@ -1120,13 +1120,13 @@ void URIUtils::CreateArchivePath(CStdString& strUrlPath,
   if( !strPwd.empty() )
   {
     strBuffer = strPwd;
-    CURL::Encode(strBuffer);
+    strBuffer = CURL::Encode(strBuffer);
     strUrlPath += strBuffer;
     strUrlPath += "@";
   }
 
   strBuffer = strArchivePath;
-  CURL::Encode(strBuffer);
+  strBuffer = CURL::Encode(strBuffer);
 
   strUrlPath += strBuffer;
 
@@ -1139,7 +1139,7 @@ void URIUtils::CreateArchivePath(CStdString& strUrlPath,
 
 #if 0 // options are not used
   strBuffer = strCachePath;
-  CURL::Encode(strBuffer);
+  strBuffer = CURL::Encode(strBuffer);
 
   strUrlPath += "?cache=";
   strUrlPath += strBuffer;