aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Kortstiege <mkortstiege@users.noreply.github.com>2015-02-06 09:12:08 +0100
committerMatthias Kortstiege <mkortstiege@users.noreply.github.com>2015-02-06 09:12:08 +0100
commit3583714a22d7bacb63a2ab36fd7b56b7e3054be7 (patch)
tree26a84445c8c46c77b873df2bec8b98b58e231c33
parent9b727df17111f004695a140966f99d93358f1563 (diff)
parenta10def9b8f0366c2b3d3fb01467b8e66bfaa83c5 (diff)
Merge pull request #6325 from arnova/ext_sub_url_encode_fix
fixed: External subtitles in custom folder did not work with url encoded files
-rw-r--r--xbmc/Util.cpp29
-rw-r--r--xbmc/utils/URIUtils.cpp7
-rw-r--r--xbmc/utils/URIUtils.h2
3 files changed, 24 insertions, 14 deletions
diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp
index 4bb7fe4df5..1f48ca684c 100644
--- a/xbmc/Util.cpp
+++ b/xbmc/Util.cpp
@@ -1865,11 +1865,11 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector<st
vector<std::string> strLookInPaths;
std::string strMovieFileName;
- std::string strPath;
+ std::string strMoviePath;
- URIUtils::Split(strMovie, strPath, strMovieFileName);
+ URIUtils::Split(strMovie, strMoviePath, strMovieFileName);
std::string strMovieFileNameNoExt(URIUtils::ReplaceExtension(strMovieFileName, ""));
- strLookInPaths.push_back(strPath);
+ strLookInPaths.push_back(strMoviePath);
CURL url(strMovie);
std::string isoFileNameNoExt;
@@ -1911,8 +1911,8 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector<st
{
CURL url(strMovie);
std::string strArchive = url.GetHostName();
- URIUtils::Split(strArchive, strPath, strMovieFileName);
- strLookInPaths.push_back(strPath);
+ URIUtils::Split(strArchive, strMoviePath, strMovieFileName);
+ strLookInPaths.push_back(strMoviePath);
}
int iSize = strLookInPaths.size();
@@ -1970,9 +1970,9 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector<st
// this is last because we dont want to check any common subdirs or cd-dirs in the alternate <subtitles> dir.
if (CMediaSettings::Get().GetAdditionalSubtitleDirectoryChecked() == 1)
{
- strPath = CSettings::Get().GetString("subtitles.custompath");
- URIUtils::AddSlashAtEnd(strPath);
- strLookInPaths.push_back(strPath);
+ std::string strPath2 = CSettings::Get().GetString("subtitles.custompath");
+ URIUtils::AddSlashAtEnd(strPath2);
+ strLookInPaths.push_back(strPath2);
}
std::string strDest;
@@ -1990,9 +1990,13 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector<st
for (int j = 0; j < items.Size(); j++)
{
- URIUtils::Split(items[j]->GetPath(), strPath, strItem);
+ std::string strSubtitlePath;
+ URIUtils::Split(items[j]->GetPath(), strSubtitlePath, strItem);
+
+ // Make sure filename uses the correct encoding
+ std::string strMovieFileNameNoExt2 = URIUtils::ChangeBasePath(strMoviePath, strMovieFileNameNoExt, strSubtitlePath, false);
- if (StringUtils::StartsWithNoCase(strItem, strMovieFileNameNoExt)
+ if (StringUtils::StartsWithNoCase(strItem, strMovieFileNameNoExt2)
|| (!isoFileNameNoExt.empty() && StringUtils::StartsWithNoCase(strItem, isoFileNameNoExt)))
{
// is this a rar or zip-file
@@ -2019,8 +2023,11 @@ void CUtil::ScanForExternalSubtitles(const std::string& strMovie, std::vector<st
// is this a rar or zip-file
if (URIUtils::IsRAR(strItem) || URIUtils::IsZIP(strItem))
{
+ // Make sure filename uses the correct encoding
+ std::string strMovieFileNameNoExt2 = URIUtils::ChangeBasePath(strMoviePath, strMovieFileNameNoExt, "", false);
+
// check strMovieFileNameNoExt in zip-file
- ScanArchiveForSubtitles( items[j]->GetPath(), strMovieFileNameNoExt, vecSubtitles );
+ ScanArchiveForSubtitles(items[j]->GetPath(), strMovieFileNameNoExt2, vecSubtitles );
}
}
}
diff --git a/xbmc/utils/URIUtils.cpp b/xbmc/utils/URIUtils.cpp
index 1127a9ac9c..5caa91ef5b 100644
--- a/xbmc/utils/URIUtils.cpp
+++ b/xbmc/utils/URIUtils.cpp
@@ -420,7 +420,7 @@ std::string URLDecodePath(const std::string& strPath)
return StringUtils::Join(segments, "/");
}
-std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath)
+std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath /* = true */)
{
std::string toFile = fromFile;
@@ -444,7 +444,10 @@ std::string URIUtils::ChangeBasePath(const std::string &fromPath, const std::str
if (!IsDOSPath(fromPath) && IsDOSPath(toPath))
StringUtils::Replace(toFile, "/", "\\");
- return AddFileToFolder(toPath, toFile);
+ if (bAddPath)
+ return AddFileToFolder(toPath, toFile);
+
+ return toFile;
}
CURL URIUtils::SubstitutePath(const CURL& url, bool reverse /* = false */)
diff --git a/xbmc/utils/URIUtils.h b/xbmc/utils/URIUtils.h
index dc280fc77b..8ddb2adf91 100644
--- a/xbmc/utils/URIUtils.h
+++ b/xbmc/utils/URIUtils.h
@@ -79,7 +79,7 @@ public:
\param toPath the base path of the resulting URL
\return the full path.
*/
- static std::string ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath);
+ static std::string ChangeBasePath(const std::string &fromPath, const std::string &fromFile, const std::string &toPath, const bool &bAddPath = true);
static CURL SubstitutePath(const CURL& url, bool reverse = false);
static std::string SubstitutePath(const std::string& strPath, bool reverse = false);