[vlc-commits] VLSub: Simplify path manipulations

Hugo Beauzée-Luyssen git at videolan.org
Tue Apr 17 14:02:21 CEST 2018


vlc/vlc-3.0 | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Mon Apr 16 17:59:18 2018 +0200| [d9a7d71eb80bf6097e921ea34d622a4a17dbb6b9] | committer: Hugo Beauzée-Luyssen

VLSub: Simplify path manipulations

Most of the info we used to extract isn't required anymore
This is now using path instead of URI, this way we will use a path when
calling path2uri back when loading the subtitle, which fixes the
convertion, and fixes loading subtitles on windows.
Fix #20114

(cherry picked from commit 31855b9c098c2c1ec0bf073dbf1723677af8805f)
Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=d9a7d71eb80bf6097e921ea34d622a4a17dbb6b9
---

 share/lua/extensions/VLSub.lua | 56 ++++--------------------------------------
 1 file changed, 5 insertions(+), 51 deletions(-)

diff --git a/share/lua/extensions/VLSub.lua b/share/lua/extensions/VLSub.lua
index c853d2a856..1b76733adf 100644
--- a/share/lua/extensions/VLSub.lua
+++ b/share/lua/extensions/VLSub.lua
@@ -1224,62 +1224,16 @@ openSub = {
     if not item then
       file.hasInput = false;
       file.cleanName = nil;
-      file.protocol = nil;
-      file.path = nil;
-      file.ext = nil;
       file.uri = nil;
     else
       vlc.msg.dbg("[VLSub] Video URI: "..item:uri())
-      local parsed_uri = vlc.strings.url_parse(item:uri())
       file.uri = item:uri()
-      file.protocol = parsed_uri["protocol"]
-      file.path = parsed_uri["path"]
-
-    -- Corrections
-
-      -- For windows
-      file.path = string.match(file.path, "^/(%a:/.+)$") or file.path
-
-      -- For file in archive
-      local archive_path, name_in_archive = string.match(
-        file.path, '^([^!]+)!/([^!/]*)$')
-      if archive_path and archive_path ~= "" then
-        file.path = string.gsub(
-          archive_path,
-          '\063',
-          '%%')
-        file.path = vlc.strings.decode_uri(file.path)
-        file.completeName = string.gsub(
-          name_in_archive,
-          '\063',
-          '%%')
-        file.completeName = vlc.strings.decode_uri(
-          file.completeName)
-        file.is_archive = true
-      else -- "classic" input
-        file.path = vlc.strings.decode_uri(file.path)
-        file.dir, file.completeName = string.match(
-          file.path,
-          '^(.*/)([^/]*)$')
-
-        local file_stat = vlc.net.stat(file.path)
-        if file_stat
-        then
-          file.stat = file_stat
-        end
-
-        file.is_archive = false
-      end
-
-      file.name, file.ext = string.match(
-        file.completeName,
-        '^([^/]-)%.?([^%.]*)$')
-
-      if file.ext == "part" then
-        file.name, file.ext = string.match(
-          file.name,
-          '^([^/]+)%.([^%.]+)$')
+      local filePath = vlc.strings.make_path(file.uri)
+      file.dir, file.name = string.match(filePath, "^(.*[".. slash .."])([^" .. slash .. "]-).?[%a%d]*$")
+      if not file.name then
+        file.name = filePath
       end
+    -- Corrections
 
       file.hasInput = true;
       file.cleanName = string.gsub(



More information about the vlc-commits mailing list