-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] %20 special character issue while navigating #2859
Comments
Confirmed. It's a bug in Cmder's custom prompt, and it exists in several places. prompt = string.gsub(prompt, "{cwd}", cwd) The A few of the calls to Cmder has a Places that use This example was missing - prompt = string.gsub(prompt, "{cwd}", cwd)
+ prompt = string.gsub(prompt, "{cwd}", verbatim(cwd)) This example needs - clink.prompt.value = string.gsub(clink.prompt.value, "{git}", " "..color.."("..verbatim(branch)..")")
+ clink.prompt.value = string.gsub(clink.prompt.value, "{git}", verbatim(" "..color.."("..branch..")")) This example needs - cwd = string.gsub(cwd, clink.get_env("HOME"), prompt_homeSymbol)
+ cwd = string.gsub(cwd, verbatim(clink.get_env("HOME")), verbatim(prompt_homeSymbol)) And so on. |
Actually, the problem affects both the third and the second parameter. I've updated my earlier response. |
@chrisant996 Thank you for the investigation! Can you please have a look at #2013 since it proposes to decode all URI-encoded characters in Also, since I'm not well versed in Lua and clink scripts, what is the purpose of |
The purpose is what the function comment and original commit description say, which handles a documented behavior of using the The original commit applied The So, maybe an even better approach would be to create a Function comment: ---
-- Makes a string safe to use as the replacement in string.gsub
---
local function verbatim(s)
s = string.gsub(s, "%%", "%%%%")
return s
end Commit description:
Wow, that's fascinating. I don't know enough about svn to say for sure whether that PR will work right for svn in all cases, but it's definitely very wrong for everything else. The issue we're discussing right now (2859) is case in point: the PR would convert It might be reasonable to instead add separate calls to EDIT: "The svn book", says that svn only uses |
I wonder if @SCWR might be saying that the svn paths in their file system literally have And SCWR wanted to decode them for display purposes since for example a path like "%48%45%4c%4c%4f" isn't human-readable (which decodes to "HELLO", by the way)? If so, then the intent behind the PR would make sense, but then it would not be a correct approach for anyone else, really. |
Fix #2859; script error when cwd name contains `%`
Version Information
Cmder Edition
Cmder Full (with Git)
Description of the issue
I just tried using thill tools. I have repository which contains a folder say My%20Home, when I navigate like : cd "My%20Home" Below error shows up.
prompt filter failed:
...\cmder\vendor\clink.lua:175: invalid capture index
stack traceback:
[C]: in function 'gsub'
...cmder\vendor\clink.lua:175: in function '?'
How to reproduce
No response
Additional context
No response
Checklist
The text was updated successfully, but these errors were encountered: