From c120527696ead79c43b254441093e971c9c14e5c Mon Sep 17 00:00:00 2001 From: "L. Yeung" Date: Tue, 23 Aug 2022 16:56:42 +0800 Subject: [PATCH] fix(cmd): escape special characters in a tip --- src/shell/scripts/omp.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/shell/scripts/omp.lua b/src/shell/scripts/omp.lua index b571a6c9..88afab1a 100644 --- a/src/shell/scripts/omp.lua +++ b/src/shell/scripts/omp.lua @@ -113,10 +113,13 @@ local function set_posh_tooltip(command) if command == nil then return end - -- escape double quote characters properly, if any - command = string.gsub(command, '\\+"', '%1%1"') - command = string.gsub(command, '\\+$', '%1%1') + + -- escape special characters properly, if any + command = string.gsub(command, '(\\+)"', '%1%1"') + command = string.gsub(command, '(\\+)$', '%1%1') command = string.gsub(command, '"', '\\"') + command = string.gsub(command, '([&<>%(%)@%^|])', '^%1') + local prompt_exe = string.format('%s print tooltip --shell=cmd %s --config=%s --command="%s"', omp_exe(), error_level_option(), omp_config(), command) local tooltip = run_posh_command(prompt_exe) if tooltip ~= "" then