diff options
author | 2019-09-25 16:47:48 -0400 | |
---|---|---|
committer | 2019-09-25 16:47:48 -0400 | |
commit | cdc2fc579977b3d7ae32f08c154928cccedf7327 (patch) | |
tree | bab3fe511c07ad98b4c624a356ba4d2426d8a706 /core/ui.lua | |
parent | 1b774a49521eff00bab0cc611f0f54b3b7f4d23b (diff) |
Fixed opening of non-UTF-8-encoded filenames dropped into a view.
Diffstat (limited to 'core/ui.lua')
-rw-r--r-- | core/ui.lua | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/core/ui.lua b/core/ui.lua index 3470392b..ae01d69f 100644 --- a/core/ui.lua +++ b/core/ui.lua @@ -300,14 +300,14 @@ events_connect(events.SAVE_POINT_LEFT, set_title) events_connect(events.URI_DROPPED, function(utf8_uris) for utf8_uri in utf8_uris:gmatch('[^\r\n]+') do if utf8_uri:find('^file://') then - local uri = utf8_uri:iconv(_CHARSET, 'UTF-8') - uri = uri:match('^file://([^\r\n]+)'):gsub('%%(%x%x)', function(hex) + local path = utf8_uri:match('^file://([^\r\n]+)') + path = path:gsub('%%(%x%x)', function(hex) return string.char(tonumber(hex, 16)) - end) + end):iconv(_CHARSET, 'UTF-8') -- In WIN32, ignore a leading '/', but not '//' (network path). - if WIN32 and not uri:match('^//') then uri = uri:sub(2, -1) end - local mode = lfs.attributes(uri, 'mode') - if mode and mode ~= 'directory' then io.open_file(uri) end + if WIN32 and not path:match('^//') then path = path:sub(2, -1) end + local mode = lfs.attributes(path, 'mode') + if mode and mode ~= 'directory' then io.open_file(path) end end end ui.goto_view(view) -- work around any view focus synchronization issues |