Skip to content

Commit 3e60f03

Browse files
committed
runtime(netrw): use fnameescape() with FileUrlEdit()
Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 2c976d0 commit 3e60f03

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

runtime/pack/dist/opt/netrw/autoload/netrw.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
" 2026 Feb 21 by Vim Project better absolute path detection on MS-Windows #19477
2323
" 2026 Feb 27 by Vim Project Make the hostname validation more strict
2424
" 2026 Mar 01 by Vim Project include portnumber in hostname checking #19533
25+
" 2026 Apr 01 by Vim Project use fnameescape() with netrw#FileUrlEdit()
2526
" Copyright: Copyright (C) 2016 Charles E. Campbell {{{1
2627
" Permission is hereby granted to use and distribute this code,
2728
" with or without modifications, provided that this copyright
@@ -8282,7 +8283,7 @@ function netrw#FileUrlEdit(fname)
82828283
endif
82838284

82848285
exe "sil doau BufReadPre ".fname2396e
8285-
exe 'NetrwKeepj keepalt edit '.plainfname
8286+
exe 'NetrwKeepj keepalt edit '. fnameescape(plainfname)
82868287
exe 'sil! NetrwKeepj keepalt bdelete '.fnameescape(a:fname)
82878288

82888289
exe "sil doau BufReadPost ".fname2396e

src/testdir/test_plugin_netrw.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,4 +595,12 @@ func Test_netrw_hostname()
595595
endfor
596596
endfunc
597597

598+
func Test_netrw_FileUrlEdit_pipe_injection()
599+
CheckExecutable id
600+
let fname = 'Xtestfile'
601+
let url = 'file:///tmp/file.md%7C!id>'..fname
602+
sil call netrw#FileUrlEdit(url)
603+
call assert_false(filereadable(fname), 'Command injection via pipe in file URL')
604+
endfunc
605+
598606
" vim:ts=8 sts=2 sw=2 et

0 commit comments

Comments
 (0)