[filesystem] handle resource paths as file paths
authorThomas Amland <thomas.amland@gmail.com>
Sun, 17 Jan 2016 16:46:06 +0000 (17:46 +0100)
committerMartijn Kaijser <mcm.kaijser@gmail.com>
Tue, 19 Jan 2016 21:27:34 +0000 (22:27 +0100)
fixes incorrect parsing of filenames containing @ characters

xbmc/URL.cpp
xbmc/filesystem/ResourceFile.cpp

index b23080d..f353a34 100644 (file)
@@ -153,7 +153,8 @@ void CURL::Parse(const std::string& strURL1)
     IsProtocol("virtualpath") ||
     IsProtocol("multipath") ||
     IsProtocol("filereader") ||
-    IsProtocol("special")
+    IsProtocol("special") ||
+    IsProtocol("resource")
     )
   {
     SetFileName(strURL.substr(iPos));
index 47f623a..8bd5fe0 100644 (file)
@@ -49,7 +49,11 @@ bool CResourceFile::TranslatePath(const CURL &url, std::string &translatedPath)
     return false;
 
   // the share name represents an identifier that can be mapped to an addon ID
-  std::string addonId = url.GetHostName();
+  std::string addonId = url.GetShareName();
+  std::string filePath;
+  if (url.GetFileName().length() > addonId.length())
+    filePath = url.GetFileName().substr(addonId.size() + 1);
+
   if (addonId.empty())
     return false;
 
@@ -61,7 +65,6 @@ bool CResourceFile::TranslatePath(const CURL &url, std::string &translatedPath)
   if (resource == NULL)
     return false;
 
-  std::string filePath = url.GetFileName();
   if (!resource->IsAllowed(filePath))
     return false;