Kaynağa Gözat

Skipped some tests for php 32-bit platform.

Ne-Lexa 8 yıl önce
ebeveyn
işleme
0d4b101510
4 değiştirilmiş dosya ile 24 ekleme ve 3 silme
  1. 4 0
      README.RU.md
  2. 4 0
      README.md
  3. 5 3
      src/PhpZip/Util/PackUtil.php
  4. 11 0
      tests/PhpZip/ZipPasswordTest.php

+ 4 - 0
README.RU.md

@@ -50,6 +50,10 @@
 - Поддержка `ZIP64` (размер файла более 4 GB или количество записей в архиве более 65535).
 - Встроенная поддержка выравнивания архива для оптимизации Android пакетов (APK) [`zipalign`](https://developer.android.com/studio/command-line/zipalign.html).
 - Работа с паролями для PHP 5.5
+> **Внимание!**
+>
+> Для 32-bit систем, в данный момент не поддерживается метод шифрование `Traditional PKWARE Encryption (ZipCrypto)`. 
+> Используйте метод шифрования `WinZIP AES Encryption`, когда это возможно.
   + Установка пароля для чтения архива глобально или для некоторых записей.
   + Изменение пароля архива, в том числе и для отдельных записей.
   + Удаление пароля архива глобально или для отдельных записей.

+ 4 - 0
README.md

@@ -50,6 +50,10 @@ Table of contents
 - Support for `ZIP64` (file size is more than 4 GB or the number of entries in the archive is more than 65535).
 - Built-in support for aligning the archive to optimize Android packages (APK) [`zipalign`](https://developer.android.com/studio/command-line/zipalign.html).
 - Working with passwords for PHP 5.5
+> **Attention!**
+>
+> For 32-bit systems, the `Traditional PKWARE Encryption (ZipCrypto)` encryption method is not currently supported. 
+> Use the encryption method `WinZIP AES Encryption`, whenever possible.
   + Set the password to read the archive for all entries or only for some.
   + Change the password for the archive, including for individual entries.
   + Delete the archive password for all or individual entries.

+ 5 - 3
src/PhpZip/Util/PackUtil.php

@@ -54,9 +54,11 @@ class PackUtil
      */
     public static function toSignedInt32($int)
     {
-        $int = $int & 0xffffffff;
-        if (PHP_INT_SIZE === 8 && ($int & 0x80000000)) {
-            return $int - 0x100000000;
+        if (PHP_INT_SIZE === 8) {
+            $int = $int & 0xffffffff;
+            if ($int & 0x80000000) {
+                return $int - 0x100000000;
+            }
         }
         return $int;
     }

+ 11 - 0
tests/PhpZip/ZipPasswordTest.php

@@ -6,6 +6,9 @@ use PhpZip\Exception\ZipAuthenticationException;
 use PhpZip\Model\ZipInfo;
 use PhpZip\Util\CryptoUtil;
 
+/**
+ * Tests with zip password.
+ */
 class ZipPasswordTest extends ZipFileAddDirTest
 {
     /**
@@ -13,6 +16,10 @@ class ZipPasswordTest extends ZipFileAddDirTest
      */
     public function testSetPassword()
     {
+        if (PHP_INT_SIZE === 4) {
+            $this->markTestSkipped('Skip test for 32-bit system. Not support Traditional PKWARE Encryption.');
+        }
+
         $password = base64_encode(CryptoUtil::randomBytes(100));
         $badPassword = "sdgt43r23wefe";
 
@@ -96,6 +103,10 @@ class ZipPasswordTest extends ZipFileAddDirTest
 
     public function testTraditionalEncryption()
     {
+        if (PHP_INT_SIZE === 4) {
+            $this->markTestSkipped('Skip test for 32-bit system. Not support Traditional PKWARE Encryption.');
+        }
+
         $password = base64_encode(CryptoUtil::randomBytes(50));
 
         $zip = new ZipFile();