runtime(zip): Opening a remote zipfile don't work

Commit: 
https://github.com/vim/vim/commit/c4be066817d560c870f67f1593630cfb5b39dfc8
Author: Damien <141588647+xrandomn...@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+xrandomn...@users.noreply.github.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/runtime/autoload/zip.vim b/runtime/autoload/zip.vim
index 79f707fbd..f77d729f0 100644
--- 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

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/E1sYqfj-003wOm-LC%40256bit.org.

Raspunde prin e-mail lui