vim/vim-7.1-netrw_urlencode.patch

65 lines
3.0 KiB
Diff

Index: vim71/runtime/autoload/netrw.vim
===================================================================
--- vim71.orig/runtime/autoload/netrw.vim
+++ vim71/runtime/autoload/netrw.vim
@@ -427,6 +427,40 @@ fun! s:NetOptionSave()
endfun
" ------------------------------------------------------------------------
+" NetUrlencode
+fun! s:NetUrlencode(str)
+ let flags='ge'
+ let r=a:str
+ let r=substitute(r,'\t','\\%09',flags)
+ let r=substitute(r,'\n','\\%0A',flags)
+ let r=substitute(r,' ','\\%20',flags)
+ let r=substitute(r,'!','\\%21',flags)
+ let r=substitute(r,'\$','\\%24',flags)
+ let r=substitute(r,"'",'\\%27',flags)
+ let r=substitute(r,'&','\\%26',flags)
+ let r=substitute(r,'(','\\%28',flags)
+ let r=substitute(r,')','\\%29',flags)
+ let r=substitute(r,'*','\\%2A',flags)
+ let r=substitute(r,'+','\\%2B',flags)
+ let r=substitute(r,',','\\%2C',flags)
+ let r=substitute(r,':','\\%3A',flags)
+ let r=substitute(r,';','\\%3B',flags)
+ let r=substitute(r,'<','\\%3C',flags)
+ let r=substitute(r,'=','\\%3D',flags)
+ let r=substitute(r,'>','\\%3E',flags)
+ let r=substitute(r,'?','\\%3F',flags)
+ let r=substitute(r,'[','\\%5B',flags)
+ let r=substitute(r,']','\\%5D',flags)
+ let r=substitute(r,'\^','\\%5E',flags)
+ let r=substitute(r,'`','\\%60',flags)
+ let r=substitute(r,'{','\\%7B',flags)
+ let r=substitute(r,'|','\\%7C',flags)
+ let r=substitute(r,'}','\\%7D',flags)
+ let r=substitute(r,'\~','\\%7E',flags)
+ return r
+endfun
+
+" ------------------------------------------------------------------------
" NetOptionRestore: restore options {{{2
fun! s:NetOptionRestore()
" call Dfunc("s:NetOptionRestore() win#".winnr()." buf#".bufnr("."))
@@ -763,7 +797,8 @@ fun! netrw#NetRead(mode,...)
" simple wget
let netrw_fname= escape(b:netrw_fname,g:netrw_fname_escape)
" call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname)
- exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_fname
+ exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".s:NetUrlencode(g:netrw_machine.netrw_fname)
+
let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
else
@@ -773,7 +808,7 @@ fun! netrw#NetRead(mode,...)
" call Decho("netrw_html<".netrw_html.">")
" call Decho("netrw_tag <".netrw_tag.">")
" call Decho("executing: !".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html)
- exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".g:netrw_machine.netrw_html
+ exe g:netrw_silentxfer."!".g:netrw_http_cmd." ".tmpfile." http://".s:NetUrlencode(g:netrw_machine.netrw_html)
let result = s:NetGetFile(readcmd, tmpfile, b:netrw_method)
" call Decho('<\s*a\s*name=\s*"'.netrw_tag.'"/')
exe 'norm! 1G/<\s*a\s*name=\s*"'.netrw_tag.'"/'."\<CR>"