[SCM] Vim packaging branch, maint/lenny, updated. debian/7.1.314-3-51-g209709e

James Vega jamessan at debian.org
Sun Oct 12 06:28:57 UTC 2008


The following commit has been merged in the maint/lenny branch:
commit 9f833c0ece10e79f720a6f2f908795bf4a7bf178
Author: James Vega <jamessan at debian.org>
Date:   Tue Oct 7 19:03:57 2008 -0400

    Update filename/shell escaping in getscript plugin
    
    Signed-off-by: James Vega <jamessan at debian.org>

diff --git a/runtime/autoload/getscript.vim b/runtime/autoload/getscript.vim
index 729be83..9222e63 100644
--- a/runtime/autoload/getscript.vim
+++ b/runtime/autoload/getscript.vim
@@ -2,7 +2,7 @@
 " getscript.vim
 "  Author:	Charles E. Campbell, Jr.
 "  Date:	May 11, 2007
-"  Version:	27
+"  Version:	27+Debian
 "  Installing:	:help glvs-install
 "  Usage:	:help glvs
 "
@@ -23,10 +23,23 @@ set cpo&vim
 if exists("g:loaded_getscript")
  finish
 endif
-let g:loaded_getscript= "v27"
+let g:loaded_getscript= "v27+Debian"
 
 " ---------------------------------------------------------------------
 "  Global Variables: {{{1
+" shell quoting character {{{2
+if exists("g:netrw_shq") && !exists("g:getscript_shq")
+ let g:getscript_shq= g:netrw_shq
+elseif !exists("g:getscript_shq")
+ if exists("&shq") && &shq != ""
+  let g:getscript_shq= &shq
+ elseif exists("&sxq") && &sxq != ""
+  let g:getscript_shq= &sxq
+ else
+  let g:getscript_shq= "'"
+ endif
+endif
+
 " allow user to change the command for obtaining scripts (does fetch work?)
 if !exists("g:GetLatestVimScripts_wget")
  if executable("wget")
@@ -192,10 +205,10 @@ fun! s:GetOneScript(...)
      exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile.' "'.scriptaddr.'"'
 	else
 "     call Decho("silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile." '".scriptaddr."'")
-     exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".tmpfile." '".scriptaddr."'"
+     exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(tmpfile)." ".s:Escape(scriptaddr)
 	endif
 	if itry == 1
-    exe "silent vsplit ".tmpfile
+    exe "silent vsplit ".fnameescape(tmpfile)
 	else
 	 silent! e %
 	endif
@@ -273,7 +286,7 @@ fun! s:GetOneScript(...)
     exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".sname.' "'.'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid.'"'
    else
 "    call Decho("unix: silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".sname." '".'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid."'")
-    exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".sname." '".'http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid."'"
+    exe "silent !".g:GetLatestVimScripts_wget." ".g:GetLatestVimScripts_options." ".s:Escape(sname)." ".s:Escape('http://vim.sf.net/scripts/download_script.php?src_id='.latestsrcid)
    endif
 
    " AutoInstall: only if doautoinstall is so indicating
@@ -281,20 +294,20 @@ fun! s:GetOneScript(...)
 "     call Decho("attempting to do autoinstall: getcwd<".getcwd()."> filereadable(".sname.")=".filereadable(sname))
      if filereadable(sname)
 "       call Decho("move <".sname."> to ".s:autoinstall)
-       exe "silent !".g:GetLatestVimScripts_mv." ".sname." ".s:autoinstall
-       let curdir= escape(substitute(getcwd(),'\','/','ge'),"|[]*'\" #")
+       exe "silent !".g:GetLatestVimScripts_mv." ".s:Escape(sname)." ".s:Escape(s:autoinstall)
+       let curdir= fnameescape(substitute(getcwd(),'\','/','ge'))
 "       call Decho("exe cd ".s:autoinstall)
-       exe "cd ".s:autoinstall
+       exe "cd ".fnameescape(s:autoinstall)
       
        " decompress
        if sname =~ '\.bz2$'
 "         call Decho("decompress: attempt to bunzip2 ".sname)
-         exe "silent !bunzip2 ".sname
+         exe "silent !bunzip2 ".s:Escape(sname)
          let sname= substitute(sname,'\.bz2$','','')
 "         call Decho("decompress: new sname<".sname."> after bunzip2")
        elseif sname =~ '\.gz$'
 "         call Decho("decompress: attempt to gunzip ".sname)
-         exe "silent !gunzip ".sname
+         exe "silent !gunzip ".s:Escape(sname)
          let sname= substitute(sname,'\.gz$','','')
 "         call Decho("decompress: new sname<".sname."> after gunzip")
        endif
@@ -302,28 +315,28 @@ fun! s:GetOneScript(...)
        " distribute archive(.zip, .tar, .vba) contents
        if sname =~ '\.zip$'
 "         call Decho("dearchive: attempt to unzip ".sname)
-         exe "silent !unzip -o ".sname
+         exe "silent !unzip -o ".s:Escape(sname)
        elseif sname =~ '\.tar$'
 "         call Decho("dearchive: attempt to untar ".sname)
-         exe "silent !tar -xvf ".sname
+         exe "silent !tar -xvf ".s:Escape(sname)
        elseif sname =~ '\.vba$'
 "         call Decho("dearchive: attempt to handle a vimball: ".sname)
          silent 1split
-         exe "silent e ".sname
+         exe "silent e ".fnameescape(sname)
          silent so %
          silent q
        endif
       
        if sname =~ '.vim$'
 "         call Decho("dearchive: attempt to simply move ".sname." to plugin")
-         exe "silent !".g:GetLatestVimScripts_mv." ".sname." plugin"
+         exe "silent !".g:GetLatestVimScripts_mv." ".s:Escape(sname)." plugin"
        endif
       
        " helptags step
        let docdir= substitute(&rtp,',.*','','e')."/doc"
 "       call Decho("helptags: docdir<".docdir.">")
-       exe "helptags ".docdir
-       exe "cd ".curdir
+       exe "helptags ".fnameescape(docdir)
+       exe "cd ".fnameescape(curdir)
      endif
      if fname !~ ':AutoInstall:'
       let modline=scriptid." ".latestsrcid." :AutoInstall: ".fname.cmmnt
@@ -350,6 +363,17 @@ fun! s:GetOneScript(...)
 endfun
 
 " ---------------------------------------------------------------------
+" s:Escape: makes a string safe&suitable for the shell {{{2
+fun! s:Escape(name)
+  if exists("*shellescape")
+   let name= shellescape(a:name)
+  else
+   let name= g:getscript_shq . a:name . g:getscript_shq
+  endif
+  return name
+endfun
+
+" ---------------------------------------------------------------------
 " GetLatestVimScripts: this function gets the latest versions of {{{1
 "                      scripts based on the list in
 "   (first dir in runtimepath)/GetLatest/GetLatestVimScripts.dat
@@ -409,9 +433,9 @@ fun! getscript#GetLatestVimScripts()
   " record current directory, change to datadir, open split window with
   " datafile
   let origdir= getcwd()
-  exe "cd ".escape(substitute(datadir,'\','/','ge'),"|[]*'\" #")
+  exe "cd ".fnameescape(substitute(datadir,'\','/','ge'))
   split
-  exe "e ".escape(substitute(datafile,'\','/','ge'),"|[]*'\" #")
+  exe "e ".fnameescape(substitute(datafile,'\','/','ge'))
   res 1000
   let s:downloads = 0
   let s:downerrors= 0
@@ -440,10 +464,12 @@ fun! getscript#GetLatestVimScripts()
    endif
 
    " read plugin in
+   " evidently a :r creates a new buffer (the "#" buffer) that is subsequently unused -- bwiping it
    $
 "   call Decho(" ")
 "   call Decho(".dependency checking<".plugin."> line$=".line("$"))
-   exe "silent r ".plugin
+   exe "silent r ".fnameescape(plugin)
+   exe "silent bwipe ".bufnr("#")
 
    while search('^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+','W') != 0
     let newscript= substitute(getline("."),'^"\s\+GetLatestVimScripts:\s\+\d\+\s\+\d\+\s\+\(.*\)$','\1','e')
@@ -487,12 +513,12 @@ fun! getscript#GetLatestVimScripts()
 "  call Decho(" ")
 
   if foundscript == 0
-   set nomod
+   setlocal nomod
   endif
 
   " Check on out-of-date scripts using GetLatest/GetLatestVimScripts.dat
 "  call Decho("begin: checking out-of-date scripts using datafile<".datafile.">")
-  set lz
+  setlocal lz
   1
 "  /^-----/,$g/^\s*\d/call Decho(getline("."))
   1
@@ -529,9 +555,9 @@ fun! getscript#GetLatestVimScripts()
   q
 
   " restore events and current directory
-  exe "cd ".escape(substitute(origdir,'\','/','ge'),"|[]*'\" #")
+  exe "cd ".fnameescape(substitute(origdir,'\','/','ge'))
   let &ei= eikeep
-  set nolz
+  setlocal nolz
 "  call Dret("GetLatestVimScripts : did ".s:downloads." downloads")
 endfun
 " ---------------------------------------------------------------------

-- 
Vim packaging



More information about the pkg-vim-maintainers mailing list