Stuk / jszip

Create, read and edit .zip files with Javascript
https://stuk.github.io/jszip/
Other
9.82k stars 1.3k forks source link

Can't unzip some zip files #925

Open cyber-sec0 opened 6 months ago

cyber-sec0 commented 6 months ago

Apparently, there are some zip files that the library is unable to unzip? I tested them with Winrar and it worked...

On the website https://subdl.com/subtitle/sd20172/white-chicks Both files below can't be unzipped by the library for some reason

English (Dvdrip) White.Chicks.DVDRip.XViD-DvP (by: Sinistral) White Chicks [Eng No Subtitles] [DVDrip] (by: uttamyadav)

` // ==UserScript== // @name Zip Extractor - SubDL // @namespace https://greasyfork.org/en/users/ // @version 1 // @description Automatically extract the subtitle file before downloading // @author me // @match https://subdl.com/subtitle/* // @require https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js // @grant none // ==/UserScript==

(function() { 'use strict'; let pendingDownloadUrl = null; //Variable to store the URL of the pending download URL

document.addEventListener('mousedown', function(event) { //Listen for clicks on the page pendingDownloadUrl = event.target.href; //Capture the download URL }); //Finishes the mousedown event listener

document.addEventListener('click', function(event) { // Intercept clicks on the page if (pendingDownloadUrl) { //If the element clicked was a link event.preventDefault(); //Prevent the default .zip file download

  fetch(pendingDownloadUrl) //Fetch the .zip file
    .then(response => { //Check if the response headers indicate a zip file
    const contentType = response.headers.get('content-type');
    return response.blob();
  }).then(blob => { //Extract the contents of the zip file
    JSZip.loadAsync(blob).then(zip => { //Extract each file
      zip.forEach((relativePath, zipEntry) => {
        zipEntry.async('blob').then(content => {
          var a = document.createElement('a'); //Create a temporary link to download the extracted file
          a.href = URL.createObjectURL(content);
          a.download = zipEntry.name; //Use the original file name
          document.body.appendChild(a);
          a.click(); //Simulate a click to trigger the download
          document.body.removeChild(a);
        });
      });
    }).catch(error => {
      document.title = 'Error extracting zip file: ' + error; //Update the document title with error message
    });
  })

  pendingDownloadUrl = null; //Reset the pending download URL
}

}); })(); `

mwildam commented 6 months ago

Looks like I have the same issue. Did not yet found out the exact zip, but I have a node project that fails building using the latest version 3.10.1. I tested with several versions and found out, that must be a change from v3.3.0 to v3.4.0 that causes the issue.

zyyzyykk commented 4 months ago

Not only zip, other formats such as img are also damaged.