mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	vim-patch:c4be066: runtime(zip): Opening a remote zipfile don't work
Problem:  Opening a zipfile from HTTP gives an empty buffer.
Solution: Ensure that the magic bytes check does not
          skip protocol processing.
Also use readblob() and remove commented out lines.
closes: vim/vim#15396
c4be066817
Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com>
			
			
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| " zip.vim: Handles browsing zipfiles | " zip.vim: Handles browsing zipfiles | ||||||
| " AUTOLOAD PORTION | " AUTOLOAD PORTION | ||||||
| " Date:		Jul 24, 2024 | " Date:		Jul 30, 2024 | ||||||
| " Version:	33 | " Version:	33 | ||||||
| " Maintainer:	This runtime file is looking for a new maintainer. | " Maintainer:	This runtime file is looking for a new maintainer. | ||||||
| " Former Maintainer:	Charles E Campbell | " Former Maintainer:	Charles E Campbell | ||||||
| @@ -8,6 +8,7 @@ | |||||||
| " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) | " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998) | ||||||
| " 2024 Jul 23 by Vim Project: fix 'x' command | " 2024 Jul 23 by Vim Project: fix 'x' command | ||||||
| " 2024 Jul 24 by Vim Project: use delete() function | " 2024 Jul 24 by Vim Project: use delete() function | ||||||
|  | " 2024 Jul 20 by Vim Project: fix opening remote zipfile | ||||||
| " License:	Vim License  (see vim's :help license) | " License:	Vim License  (see vim's :help license) | ||||||
| " Copyright:	Copyright (C) 2005-2019 Charles E. Campbell {{{1 | " Copyright:	Copyright (C) 2005-2019 Charles E. Campbell {{{1 | ||||||
| "		Permission is hereby granted to use and distribute this code, | "		Permission is hereby granted to use and distribute this code, | ||||||
| @@ -73,15 +74,11 @@ endif | |||||||
| " --------------------------------------------------------------------- | " --------------------------------------------------------------------- | ||||||
| " zip#Browse: {{{2 | " zip#Browse: {{{2 | ||||||
| fun! zip#Browse(zipfile) | fun! zip#Browse(zipfile) | ||||||
| "  call Dfunc("zip#Browse(zipfile<".a:zipfile.">)") |   " sanity check: ensure that the zipfile has "PK" as its first two letters | ||||||
|   " sanity check: insure that the zipfile has "PK" as its first two letters |   "               (zip files have a leading PK as a "magic cookie") | ||||||
|   "               (zipped files have a leading PK as a "magic cookie") |   if filereadable(a:zipfile) && readblob(a:zipfile, 0, 2) != 0z50.4B | ||||||
|   if !filereadable(a:zipfile) || readfile(a:zipfile, "", 1)[0] !~ '^PK' |    exe "noswapfile noautocmd e " .. fnameescape(a:zipfile) | ||||||
|    exe "noswapfile noautocmd noswapfile e ".fnameescape(a:zipfile) |  | ||||||
| "   call Dret("zip#Browse : not a zipfile<".a:zipfile.">") |  | ||||||
|    return |    return | ||||||
| "  else        " Decho |  | ||||||
| "   call Decho("zip#Browse: a:zipfile<".a:zipfile."> passed PK test - it's a zip file") |  | ||||||
|   endif |   endif | ||||||
|  |  | ||||||
|   let repkeep= &report |   let repkeep= &report | ||||||
| @@ -97,9 +94,7 @@ fun! zip#Browse(zipfile) | |||||||
|   if !executable(g:zip_unzipcmd) |   if !executable(g:zip_unzipcmd) | ||||||
|    redraw! |    redraw! | ||||||
|    echohl Error | echo "***error*** (zip#Browse) unzip not available on your system" |    echohl Error | echo "***error*** (zip#Browse) unzip not available on your system" | ||||||
| "   call inputsave()|call input("Press <cr> to continue")|call inputrestore() |  | ||||||
|    let &report= repkeep |    let &report= repkeep | ||||||
| "   call Dret("zip#Browse") |  | ||||||
|    return |    return | ||||||
|   endif |   endif | ||||||
|   if !filereadable(a:zipfile) |   if !filereadable(a:zipfile) | ||||||
| @@ -107,13 +102,10 @@ fun! zip#Browse(zipfile) | |||||||
|     " if it's an url, don't complain, let url-handlers such as vim do its thing |     " if it's an url, don't complain, let url-handlers such as vim do its thing | ||||||
|     redraw! |     redraw! | ||||||
|     echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None |     echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None | ||||||
| "    call inputsave()|call input("Press <cr> to continue")|call inputrestore() |  | ||||||
|    endif |    endif | ||||||
|    let &report= repkeep |    let &report= repkeep | ||||||
| "   call Dret("zip#Browse : file<".a:zipfile."> not readable") |  | ||||||
|    return |    return | ||||||
|   endif |   endif | ||||||
| "  call Decho("passed sanity checks") |  | ||||||
|   if &ma != 1 |   if &ma != 1 | ||||||
|    set ma |    set ma | ||||||
|   endif |   endif | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Christian Clason
					Christian Clason