From 0e96f7d04c1fedb5ed29e21ef4121e2ce3661673 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 26 Dec 2021 16:39:03 -0500 Subject: [PATCH] fix(uri): change scheme pattern to not include the comma character (#16798) (cherry picked from commit efbe306d2d105d16c4690c6b27da0554c43d88f1) Co-authored-by: Dmytro Meleshko --- runtime/lua/vim/uri.lua | 4 ++-- test/functional/lua/uri_spec.lua | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/lua/vim/uri.lua b/runtime/lua/vim/uri.lua index d08d2a3ee3..11b661cd1a 100644 --- a/runtime/lua/vim/uri.lua +++ b/runtime/lua/vim/uri.lua @@ -74,8 +74,8 @@ local function uri_from_fname(path) return table.concat(uri_parts) end -local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):.*' -local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9+-.]*):[a-zA-Z]:.*' +local URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9.+-]*):.*' +local WINDOWS_URI_SCHEME_PATTERN = '^([a-zA-Z]+[a-zA-Z0-9.+-]*):[a-zA-Z]:.*' --- Get a URI from a bufnr ---@param bufnr number diff --git a/test/functional/lua/uri_spec.lua b/test/functional/lua/uri_spec.lua index dbfbe2dbfe..fa11fdf794 100644 --- a/test/functional/lua/uri_spec.lua +++ b/test/functional/lua/uri_spec.lua @@ -155,6 +155,12 @@ describe('URI methods', function() return pcall(vim.uri_to_fname, 'not_an_uri.txt') ]]) end) + + it('uri_to_fname should not treat comma as a scheme character', function() + eq(false, exec_lua [[ + return pcall(vim.uri_to_fname, 'foo,://bar') + ]]) + end) end) end)