diff options
author | Anton Fedchin <anightik@gmail.com> | 2018-03-30 15:19:36 +0300 |
---|---|---|
committer | Anton Fedchin <anightik@gmail.com> | 2018-03-30 15:31:54 +0300 |
commit | da85879061fb7a73da9b1df02f4eb029759fa50c (patch) | |
tree | d75d8c04e40c6b9d520c6907936d43b1d1fe3847 | |
parent | 59c7bc939d9ada03dd19c08fafda6b5eb6f2d677 (diff) |
[filesystem] don't change auths for an url if the auth is set explicitly
-rw-r--r-- | xbmc/filesystem/Directory.cpp | 25 | ||||
-rw-r--r-- | xbmc/filesystem/File.cpp | 24 |
2 files changed, 29 insertions, 20 deletions
diff --git a/xbmc/filesystem/Directory.cpp b/xbmc/filesystem/Directory.cpp index 10c251c8fe..2d9a237c41 100644 --- a/xbmc/filesystem/Directory.cpp +++ b/xbmc/filesystem/Directory.cpp @@ -165,12 +165,14 @@ bool CDirectory::GetDirectory(const CURL& url, CFileItemList &items, const CHint pDirectory->SetFlags(hints.flags); bool result = false, cancel = false; + CURL authUrl = CURL(realURL); + while (!result && !cancel) { const std::string pathToUrl(url.Get()); - CURL authUrl = CURL(realURL); - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + // don't change auth if it's set explicitly + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); if (g_application.IsCurrentThread() && allowThreads && !URIUtils::IsSpecial(pathToUrl)) @@ -195,8 +197,15 @@ bool CDirectory::GetDirectory(const CURL& url, CFileItemList &items, const CHint if (!result) { - if (!cancel && g_application.IsCurrentThread() && pDirectory->ProcessRequirements()) - continue; + if (!cancel) + { + if (g_application.IsCurrentThread() && pDirectory->ProcessRequirements()) + { + authUrl.SetUserName(""); + authUrl.SetPassword(""); + continue; + } + } CLog::Log(LOGERROR, "%s - Error getting %s", __FUNCTION__, url.GetRedacted().c_str()); return false; } @@ -288,7 +297,7 @@ bool CDirectory::Create(const CURL& url) { CURL realURL = URIUtils::SubstitutePath(url); - if (CPasswordManager::GetInstance().IsURLSupported(realURL)) + if (CPasswordManager::GetInstance().IsURLSupported(realURL) && realURL.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(realURL); std::unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL)); @@ -327,7 +336,7 @@ bool CDirectory::Exists(const CURL& url, bool bUseCache /* = true */) return false; } - if (CPasswordManager::GetInstance().IsURLSupported(realURL)) + if (CPasswordManager::GetInstance().IsURLSupported(realURL) && realURL.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(realURL); std::unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL)); @@ -360,7 +369,7 @@ bool CDirectory::Remove(const CURL& url) { CURL realURL = URIUtils::SubstitutePath(url); CURL authUrl = realURL; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); std::unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL)); @@ -386,7 +395,7 @@ bool CDirectory::RemoveRecursive(const CURL& url) { CURL realURL = URIUtils::SubstitutePath(url); CURL authUrl = realURL; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); std::unique_ptr<IDirectory> pDirectory(CDirectoryFactory::Create(realURL)); diff --git a/xbmc/filesystem/File.cpp b/xbmc/filesystem/File.cpp index 7a2bc3143c..3b02c6e9b0 100644 --- a/xbmc/filesystem/File.cpp +++ b/xbmc/filesystem/File.cpp @@ -316,7 +316,7 @@ bool CFile::Open(const CURL& file, const unsigned int flags) return false; CURL authUrl(url); - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); try @@ -342,7 +342,7 @@ bool CFile::Open(const CURL& file, const unsigned int flags) if (pNewUrl.get()) { CURL newAuthUrl(*pNewUrl); - if (CPasswordManager::GetInstance().IsURLSupported(newAuthUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(newAuthUrl) && newAuthUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(newAuthUrl); if (!m_pFile->Open(newAuthUrl)) @@ -403,7 +403,7 @@ bool CFile::OpenForWrite(const CURL& file, bool bOverWrite) { CURL url = URIUtils::SubstitutePath(file); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); m_pFile = CFileFactory::CreateLoader(url); @@ -435,7 +435,7 @@ bool CFile::Exists(const CURL& file, bool bUseCache /* = true */) { CURL url(URIUtils::SubstitutePath(file)); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); try @@ -480,7 +480,7 @@ bool CFile::Exists(const CURL& file, bool bUseCache /* = true */) return false; } CURL newAuthUrl = *pNewUrl; - if (CPasswordManager::GetInstance().IsURLSupported(newAuthUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(newAuthUrl) && newAuthUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(newAuthUrl); return pImp->Exists(newAuthUrl); @@ -528,7 +528,7 @@ int CFile::Stat(const CURL& file, struct __stat64* buffer) CURL url(URIUtils::SubstitutePath(file)); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); try @@ -555,7 +555,7 @@ int CFile::Stat(const CURL& file, struct __stat64* buffer) if (pImp.get()) { CURL newAuthUrl = *pNewUrl; - if (CPasswordManager::GetInstance().IsURLSupported(newAuthUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(newAuthUrl) && newAuthUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(newAuthUrl); if (!pImp->Stat(newAuthUrl, buffer)) @@ -878,7 +878,7 @@ bool CFile::Delete(const CURL& file) { CURL url(URIUtils::SubstitutePath(file)); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); std::unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url)); @@ -916,10 +916,10 @@ bool CFile::Rename(const CURL& file, const CURL& newFile) CURL urlnew(URIUtils::SubstitutePath(newFile)); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); CURL authUrlNew = urlnew; - if (CPasswordManager::GetInstance().IsURLSupported(authUrlNew)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrlNew) && authUrlNew.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrlNew); std::unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url)); @@ -954,7 +954,7 @@ bool CFile::SetHidden(const CURL& file, bool hidden) { CURL url(URIUtils::SubstitutePath(file)); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); std::unique_ptr<IFile> pFile(CFileFactory::CreateLoader(url)); @@ -1236,7 +1236,7 @@ bool CFileStream::Open(const CURL& filename) m_file = CFileFactory::CreateLoader(url); CURL authUrl = url; - if (CPasswordManager::GetInstance().IsURLSupported(authUrl)) + if (CPasswordManager::GetInstance().IsURLSupported(authUrl) && authUrl.GetUserName().empty()) CPasswordManager::GetInstance().AuthenticateURL(authUrl); if(m_file && m_file->Open(authUrl)) |