Skip to content

Commit 27f5334

Browse files
Ubaldo Tiberichrisbra
authored andcommitted
runtime(termdebug): quote filename arguments using double quotes
closes: #15270 Signed-off-by: Ubaldo Tiberi <ubaldo.tiberi@google.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 1724ddb commit 27f5334

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

runtime/pack/dist/opt/termdebug/plugin/termdebug.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,11 @@ def DeleteCommands()
13251325
sign_undefine(BreakpointSigns->map("'debugBreakpoint' .. v:val"))
13261326
enddef
13271327

1328+
def QuoteArg(x: string): string
1329+
# Find all the occurrences of " and \ and escape them and double quote
1330+
# the resulting string.
1331+
return printf('"%s"', x ->substitute('[\\"]', '\\&', 'g'))
1332+
enddef
13281333

13291334
# :Until - Execute until past a specified position or current line
13301335
def Until(at: string)
@@ -1335,7 +1340,7 @@ def Until(at: string)
13351340
ch_log('assume that program is running after this command')
13361341

13371342
# Use the fname:lnum format
1338-
var AT = empty(at) ? $"\"{expand('%:p')}:{line('.')}\"" : at
1343+
var AT = empty(at) ? QuoteArg($"{expand('%:p')}:{line('.')}") : at
13391344
SendCommand($'-exec-until {AT}')
13401345
else
13411346
ch_log('dropping command, program is running: exec-until')
@@ -1354,7 +1359,7 @@ def SetBreakpoint(at: string, tbreak=false)
13541359
endif
13551360

13561361
# Use the fname:lnum format, older gdb can't handle --source.
1357-
var AT = empty(at) ? $"\"{expand('%:p')}:{line('.')}\"" : at
1362+
var AT = empty(at) ? QuoteArg($"{expand('%:p')}:{line('.')}") : at
13581363
var cmd = ''
13591364
if tbreak
13601365
cmd = $'-break-insert -t {AT}'

0 commit comments

Comments
 (0)