fix(loader): cache path ambiguity #24491

Problem: cache paths are derived by replacing each reserved/filesystem-
path-sensitive char with a `%` char in the original path. With this
method, two different files at two different paths (each containing `%`
chars) can erroneously resolve to the very same cache path in certain
edge-cases.

Solution: derive cache paths by url-encoding the original (path) instead
using `vim.uri_encode()` with `"rfc2396"`. Increment `Loader.VERSION` to
denote this change.
This commit is contained in:
Tyler Miller
2023-08-01 08:28:28 -07:00
committed by GitHub
parent dfe19d6e00
commit 0804034c07
4 changed files with 99 additions and 56 deletions

View File

@@ -2428,8 +2428,27 @@ vim.loader.reset({path}) *vim.loader.reset()*
==============================================================================
Lua module: vim.uri *vim.uri*
vim.uri_decode({str}) *vim.uri_decode()*
URI-decodes a string containing percent escapes.
Parameters: ~
• {str} (string) string to decode
Return: ~
(string) decoded string
vim.uri_encode({str}, {rfc}) *vim.uri_encode()*
URI-encodes a string using percent escapes.
Parameters: ~
• {str} (string) string to encode
• {rfc} "rfc2396" | "rfc2732" | "rfc3986" | nil
Return: ~
(string) encoded string
vim.uri_from_bufnr({bufnr}) *vim.uri_from_bufnr()*
Get a URI from a bufnr
Gets a URI from a bufnr.
Parameters: ~
• {bufnr} (integer)
@@ -2438,7 +2457,7 @@ vim.uri_from_bufnr({bufnr}) *vim.uri_from_bufnr()*
(string) URI
vim.uri_from_fname({path}) *vim.uri_from_fname()*
Get a URI from a file path.
Gets a URI from a file path.
Parameters: ~
• {path} (string) Path to file
@@ -2447,7 +2466,7 @@ vim.uri_from_fname({path}) *vim.uri_from_fname()*
(string) URI
vim.uri_to_bufnr({uri}) *vim.uri_to_bufnr()*
Get the buffer for a uri. Creates a new unloaded buffer if no buffer for
Gets the buffer for a uri. Creates a new unloaded buffer if no buffer for
the uri already exists.
Parameters: ~
@@ -2457,7 +2476,7 @@ vim.uri_to_bufnr({uri}) *vim.uri_to_bufnr()*
(integer) bufnr
vim.uri_to_fname({uri}) *vim.uri_to_fname()*
Get a filename from a URI
Gets a filename from a URI.
Parameters: ~
• {uri} (string)