changeset 35853:4428964807a0

runtime(zip): Opening a remote zipfile don't work Commit: https://github.com/vim/vim/commit/c4be066817d560c870f67f1593630cfb5b39dfc8 Author: Damien <141588647+xrandomname@users.noreply.github.com> Date: Tue Jul 30 19:14:35 2024 +0200 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: #15396 Signed-off-by: Damien <141588647+xrandomname@users.noreply.github.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 30 Jul 2024 19:30:03 +0200
parents c29299dcb8eb
children 26e0c3d37fef
files runtime/autoload/zip.vim
diffstat 1 files changed, 6 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/autoload/zip.vim
+++ b/runtime/autoload/zip.vim
@@ -1,6 +1,6 @@
 " zip.vim: Handles browsing zipfiles
 " AUTOLOAD PORTION
-" Date:		Jul 24, 2024
+" Date:		Jul 30, 2024
 " Version:	33
 " Maintainer:	This runtime file is looking for a new maintainer.
 " Former Maintainer:	Charles E Campbell
@@ -8,6 +8,7 @@
 " 2024 Jun 16 by Vim Project: handle whitespace on Windows properly (#14998)
 " 2024 Jul 23 by Vim Project: fix 'x' command
 " 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)
 " Copyright:	Copyright (C) 2005-2019 Charles E. Campbell {{{1
 "		Permission is hereby granted to use and distribute this code,
@@ -73,15 +74,11 @@ endif
 " ---------------------------------------------------------------------
 " zip#Browse: {{{2
 fun! zip#Browse(zipfile)
-"  call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
-  " sanity check: insure that the zipfile has "PK" as its first two letters
-  "               (zipped files have a leading PK as a "magic cookie")
-  if !filereadable(a:zipfile) || readfile(a:zipfile, "", 1)[0] !~ '^PK'
-   exe "noswapfile noautocmd noswapfile e ".fnameescape(a:zipfile)
-"   call Dret("zip#Browse : not a zipfile<".a:zipfile.">")
+  " sanity check: ensure that the zipfile has "PK" as its first two letters
+  "               (zip files have a leading PK as a "magic cookie")
+  if filereadable(a:zipfile) && readblob(a:zipfile, 0, 2) != 0z50.4B
+   exe "noswapfile noautocmd e " .. fnameescape(a:zipfile)
    return
-"  else        " Decho
-"   call Decho("zip#Browse: a:zipfile<".a:zipfile."> passed PK test - it's a zip file")
   endif
 
   let repkeep= &report
@@ -97,9 +94,7 @@ fun! zip#Browse(zipfile)
   if !executable(g:zip_unzipcmd)
    redraw!
    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
-"   call Dret("zip#Browse")
    return
   endif
   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
     redraw!
     echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
-"    call inputsave()|call input("Press <cr> to continue")|call inputrestore()
    endif
    let &report= repkeep
-"   call Dret("zip#Browse : file<".a:zipfile."> not readable")
    return
   endif
-"  call Decho("passed sanity checks")
   if &ma != 1
    set ma
   endif