From 27d636a5793f25bc5e73df62490daefbfd711c45 Mon Sep 17 00:00:00 2001 From: arnova Date: Wed, 4 Sep 2019 19:42:26 +0200 Subject: [PATCH] fixed: External subtitles in custom folder were not picked up due to not considering URL-encoding (fixes #16567) --- xbmc/Util.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xbmc/Util.cpp b/xbmc/Util.cpp index 6277624b8cf88..f223fd99ff475 100644 --- a/xbmc/Util.cpp +++ b/xbmc/Util.cpp @@ -1924,7 +1924,8 @@ void CUtil::ScanPathsForAssociatedItems(const std::string& videoName, continue; URIUtils::RemoveExtension(strCandidate); - if (StringUtils::StartsWithNoCase(strCandidate, videoName)) + // NOTE: We don't know if one of videoName or strCandidate is URL-encoded and the other is not, so try both + if (StringUtils::StartsWithNoCase(strCandidate, videoName) || (StringUtils::StartsWithNoCase(strCandidate, CURL::Decode(videoName)))) { if (URIUtils::IsRAR(pItem->GetPath()) || URIUtils::IsZIP(pItem->GetPath())) CUtil::ScanArchiveForAssociatedItems(pItem->GetPath(), "", item_exts, associatedFiles); @@ -1973,7 +1974,10 @@ int CUtil::ScanArchiveForAssociatedItems(const std::string& strArchivePath, // check that the found filename matches the movie filename size_t fnl = videoNameNoExt.size(); - if (fnl && !StringUtils::StartsWithNoCase(URIUtils::GetFileName(strPathInRar), videoNameNoExt)) + // NOTE: We don't know if videoNameNoExt is URL-encoded, so try both + if (fnl && + !(StringUtils::StartsWithNoCase(URIUtils::GetFileName(strPathInRar), videoNameNoExt) || + StringUtils::StartsWithNoCase(URIUtils::GetFileName(strPathInRar), CURL::Decode(videoNameNoExt)))) continue; for (auto ext : item_exts)