16 Commits
master ... v4.x

Author SHA1 Message Date
macintoshplus
38fe9a67c4 add Funding 2026-02-25 12:40:55 +01:00
Jean-Baptiste Nahan
1a623543c4 Merge pull request #2 from php-win-ext/clean_repo
📝 clean repo and add some informations
2026-02-25 09:32:08 +01:00
macintoshplus
cfffb63b5a 📝 clean repo and add some informations 2026-02-25 00:48:39 +01:00
Jean-Baptiste Nahan
c99b6925ad Merge pull request #1 from php-win-ext/add_build_release
Update Code and Tests
2026-02-25 00:37:02 +01:00
macintoshplus
792c622f3e remove php 8.1 limitation for Windows test 2026-02-25 00:28:11 +01:00
macintoshplus
3f507ce2db update test for Windows x86 platform 2026-02-25 00:25:46 +01:00
macintoshplus
7ba9c28e15 try fix test 092 on Windows 2026-02-25 00:05:22 +01:00
macintoshplus
717d75ec8e add dump in test for debug test on windows 2026-02-24 23:49:33 +01:00
macintoshplus
498286b7af 👷 fix Windows test 041 fail 2026-02-24 23:35:48 +01:00
macintoshplus
d1c7fcd5a1 👷 fix test for Windows 2026-02-24 23:33:42 +01:00
macintoshplus
55d30dfa5d enable window CI for branches 2026-02-24 23:23:26 +01:00
macintoshplus
52f8a34342 🔧 update gitignore 2026-02-24 23:20:57 +01:00
macintoshplus
5a930a03aa 💚 fix CI PHP TS value 2026-02-24 23:18:14 +01:00
macintoshplus
234a78c2f7 💚 fix CI for PHP 8.5 2026-02-24 23:15:05 +01:00
macintoshplus
19b94313c2 update code for PHP 8.2+ 2026-02-24 22:48:56 +01:00
macintoshplus
7b2749af57 Add GitHub workflow and PIE Configuration 2026-02-24 22:11:42 +01:00
32 changed files with 187 additions and 258 deletions

13
.github/FUNDING.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
# These are supported funding model platforms
github: [macintoshplus] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
# patreon: # Replace with a single Patreon username
# open_collective: # Replace with a single Open Collective username
# ko_fi: # Replace with a single Ko-fi username
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
# liberapay: # Replace with a single Liberapay username
# issuehunt: # Replace with a single IssueHunt username
# otechie: # Replace with a single Otechie username
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

27
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: CI
on:
push:
branches: ['*']
jobs:
test-linux:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php-rel: ['8.2', '8.3', '8.4', '8.5']
ts-state: [ts, nts]
steps:
- uses: actions/checkout@v5
- name: Setup PHP
id: setup-php
uses: shivammathur/setup-php@v2
with:
php-version: '${{ matrix.php-rel }}'
env:
phpts: '${{ matrix.ts-state }}'
- name: build extension
run: phpize && ./configure --enable-rar && make
- name: run tests
run: rm run-tests.php && cp run-tests8.php run-tests.php && make test

49
.github/workflows/windows.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
name: Publish Windows Releases
on:
release:
types: [created]
push:
branches: ['*']
permissions:
contents: write
jobs:
get-extension-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.extension-matrix.outputs.matrix }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Get the extension matrix
id: extension-matrix
uses: php/php-windows-builder/extension-matrix@v1
build:
needs: get-extension-matrix
runs-on: ${{ matrix.os }}
continue-on-error: false
strategy:
fail-fast: true
matrix: ${{fromJson(needs.get-extension-matrix.outputs.matrix)}}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Build the extension
uses: php/php-windows-builder/extension@v1
with:
php-version: ${{ matrix.php-version }}
arch: ${{ matrix.arch }}
ts: ${{ matrix.ts }}
args: '--enable-rar'
test-runner: 'run-tests8.php'
release:
runs-on: ubuntu-latest
needs: build
if: ${{ github.event_name == 'release' }}
steps:
- name: Upload artifact to the release
uses: php/php-windows-builder/release@v1
with:
release: ${{ github.event.release.tag_name }}
# token: ${{ secrets.GITHUB_TOKEN }}

1
.gitignore vendored
View File

@@ -11,6 +11,7 @@
/modules
/missing
/.deps
*.dep
/.libs
/Makefile
/Makefile.fragments

View File

@@ -10,6 +10,33 @@ unrar/LICENSE.txt for details.
Some modifications have been applied to the UnRAR library, mainly to allow
streaming extraction of files without using threads.
[![Build Status Appveyor](https://ci.appveyor.com/api/projects/status/cbgpepx6kyax2198/branch/master?svg=true)](https://ci.appveyor.com/project/cataphract/php-rar/branch/master)
[![Build Status Travis](https://travis-ci.org/cataphract/php-rar.svg?branch=master)](https://travis-ci.org/cataphract/php-rar)
[![codecov](https://codecov.io/gh/cataphract/php-rar/branch/master/graph/badge.svg)](https://codecov.io/gh/cataphract/php-rar)
| Version | Status |
|---------|------------------------------|
| master | unmaintened :x: |
| v4.x | maintened :white_check_mark: |
Maintained PHP Versions compatibility:
| PHP Version | Status |
|-------------|------------------------|
| 5.x | no :x: |
| 7.x | no :x: |
| 8.0 | yes :white_check_mark: |
| 8.1 | yes :white_check_mark: |
| 8.2 | yes :white_check_mark: |
| 8.3 | yes :white_check_mark: |
| 8.4 | yes :white_check_mark: |
| 8.5 | yes :white_check_mark: |
Installation system support:
| Platform | Status |
|----------|------------------------|
| PECL | no :x: |
| PIE | yes :white_check_mark: |
To install the extension, use PIE (PHP Installer Extension) with a command like:
```bash
pie install php-win-ext/rar
```

View File

@@ -1,31 +0,0 @@
echo Running appveyor.bat
echo on
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
IF NOT EXIST "C:\projects\php-sdk" (
wget -nv http://windows.php.net/downloads/php-sdk/php-sdk-binary-tools-20110915.zip
7z x -y php-sdk-binary-tools-20110915.zip -oC:\projects\php-sdk
)
IF NOT EXIST "C:\projects\php-src\Release_TS\php7ts.lib" (
git clone --depth=1 --branch=PHP-7.1 https://github.com/php/php-src C:\projects\php-src
wget -nv http://windows.php.net/downloads/php-sdk/deps-7.1-vc14-x86.7z
7z x -y deps-7.1-vc14-x86.7z -oC:\projects\php-src
CALL C:\projects\php-sdk\bin\phpsdk_setvars.bat
cd C:\projects\php-src
CALL buildconf.bat
CALL configure.bat --disable-all --enable-cli --with-config-file-scan-dir=C:\projects\extension\bin\modules.d --with-prefix=%APPVEYOR_BUILD_FOLDER%\bin --with-php-build=deps
nmake
) ELSE (
echo php7ts.lib already exists
cd C:\projects\php-src
CALL C:\projects\php-sdk\bin\phpsdk_setvars.bat
)
CALL buildconf.bat --force --add-modules-dir=%APPVEYOR_BUILD_FOLDER%\..
CALL configure.bat --disable-all --enable-cli --enable-rar=shared --with-config-file-scan-dir=C:\projects\extension\bin\modules.d --with-prefix=%APPVEYOR_BUILD_FOLDER%\bin --with-php-build=deps
nmake || exit /b
rmdir Release_TS\php-rar /S /Q
del /S /Q "Release_TS\*.sbr"
copy %APPVEYOR_BUILD_FOLDER%\run-tests8.php C:\projects\php-src\run-tests.php

View File

@@ -1,26 +0,0 @@
# Based on igbinary's appveyor config.
version: '{branch}.{build}'
install:
- cmd: choco feature enable -n=allowGlobalConfirmation
- cmd: cinst wget
- cmd: mkdir %APPVEYOR_BUILD_FOLDER%\bin
build_script:
- cmd: "%APPVEYOR_BUILD_FOLDER%\\appveyor.bat"
test_script:
- cmd: cd C:\projects\php-src
- cmd: set NO_INTERACTION=1
- cmd: set REPORT_EXIT_STATUS=1
- cmd: set TZ=UTC
- cmd: 'nmake test TESTS="--show-diff --set-timeout 30 -d extension=C:\projects\php-src\Release_TS\php_rar.dll %APPVEYOR_BUILD_FOLDER%\tests"'
after_test:
# - cmd: dir /S C:\projects\php-src\Release_TS
- cmd: 'del C:\projects\php-src\Release_TS\php_rar.*'
cache:
- C:\ProgramData\chocolatey\lib -> appveyor.yml
- C:\projects\php-src
- C:\projects\php-sdk

View File

@@ -1,85 +0,0 @@
jobs:
- template: azure-template.yml
parameters:
name: php_5_3_valgrind
displayName: PHP 5.3 ZTS (valgrind, clang)
phpVersion: '5.3'
clang: true
valgrind: true
zts: true
- template: azure-template.yml
parameters:
name: php_5_4
displayName: PHP 5.4
phpVersion: '5.4'
- template: azure-template.yml
parameters:
name: php_5_5
displayName: PHP 5.5
phpVersion: '5.5'
- template: azure-template.yml
parameters:
name: php_5_6
displayName: PHP 5.6
phpVersion: '5.6'
- template: azure-template.yml
parameters:
name: php_5_6_valgrind
displayName: PHP 5.6 ZTS (valgrind, clang)
phpVersion: '5.6'
clang: true
valgrind: true
zts: true
- template: azure-template.yml
parameters:
name: php_7_0
displayName: PHP 7.0
phpVersion: '7.0'
- template: azure-template.yml
parameters:
name: php_7_1
displayName: PHP 7.1
phpVersion: '7.1'
- template: azure-template.yml
parameters:
name: php_7_2
displayName: PHP 7.2
phpVersion: '7.2'
- template: azure-template.yml
parameters:
name: php_7_3
displayName: PHP 7.3
phpVersion: '7.3'
- template: azure-template.yml
parameters:
name: php_7_4
displayName: PHP 7.4 ZTS (valgrind, clang)
phpVersion: '7.4'
clang: true
valgrind: true
zts: true
- template: azure-template.yml
parameters:
name: php_8_0
displayName: PHP 8.0 ZTS
phpVersion: '8.0'
zts: true
publishCoverage: true
- template: azure-template.yml
parameters:
name: php_8_0_valgrind
displayName: PHP 8.0 (valgrind, clang)
phpVersion: '8.0'
clang: true
valgrind: true

View File

@@ -1,65 +0,0 @@
parameters:
name: ~
displayName: ~
phpVersion: bundled
imageName: ubuntu-20.04
zts: false
clang: false
publishCoverage: false
valgrind: false
jobs:
- job: ${{ parameters.name }}
displayName: ${{ parameters.displayName }}
pool:
vmImage: ${{ parameters.imageName }}
variables:
${{ if eq(parameters.clang, true) }}:
CC: clang
CXX: clang++
steps:
- checkout: self
displayName: Checkout
clean: true
submodules: recursive
- bash: |
source test_funcs.sh
install_php ${{ parameters.phpVersion }} ${{ parameters.zts }}
displayName: Install PHP ${{ parameters.phpVersion }}
- ${{ if eq(parameters.valgrind, true) }}:
- bash: >
sudo apt-get install valgrind
displayName: "Install Valgrind"
- script: |
source test_funcs.sh
build_ext ${{ parameters.phpVersion }} ${{ parameters.zts }} ${{ parameters.publishCoverage }}
displayName: Build extension
- script: |
source test_funcs.sh
run_tests ${{ parameters.phpVersion }} ${{ parameters.zts }} ${{ parameters.publishCoverage }}
${{ if eq(parameters.valgrind, true) }}:
env:
RUN_TESTS_FLAGS: -m
displayName: Run tests
- task: PublishTestResults@2
displayName: Publish test results
condition: succeededOrFailed()
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: 'report.xml'
searchFolder: '$(System.DefaultWorkingDirectory)'
mergeTestResults: true
- ${{ if eq(parameters.publishCoverage, true) }}:
- bash: >
bash <(curl -s https://codecov.io/bash)
displayName: "Publish coverage (Codecov)"
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)

View File

@@ -1,8 +1,8 @@
{
"name": "rar",
"type": "extension",
"name": "php-win-ext/rar",
"type": "php-ext",
"license": [
"PHP License"
"PHP-3.01"
],
"authors": [
{
@@ -14,5 +14,8 @@
"email": "tony@daylessday.org"
}
],
"require": {
"php": ">= 8.0.0"
},
"description": "rar extension"
}

View File

@@ -31,7 +31,7 @@ if (PHP_RAR != "no") {
arcread.cpp filefn.cpp \
global.cpp list.cpp \
encname.cpp file.cpp \
secpassword.cpp options.cpp", "rar");
secpassword.cpp options.cpp", "rar", "unrar_obj");
AC_DEFINE("HAVE_RAR", 1, "Rar support");
}

View File

@@ -51,7 +51,7 @@
extern zend_module_entry rar_module_entry;
#define phpext_rar_ptr &rar_module_entry
#define PHP_RAR_VERSION "4.2.0"
#define PHP_RAR_VERSION "4.2.1"
#ifdef PHP_WIN32
#define PHP_RAR_API __declspec(dllexport)

View File

@@ -247,7 +247,7 @@ void minit_rarerror(TSRMLS_D) /* {{{ */
zend_exception_get_default(TSRMLS_C), NULL TSRMLS_CC);
#else
rarexception_ce_ptr = zend_register_internal_class_ex(&ce,
zend_exception_get_default(TSRMLS_C));
zend_ce_exception);
#endif
rarexception_ce_ptr->ce_flags |= ZEND_ACC_FINAL;
zend_declare_property_bool(rarexception_ce_ptr, "usingExceptions",

View File

@@ -544,7 +544,8 @@ static int rararch_dimensions_preamble(rar_file_t *rar,
/* }}} */
/* {{{ RarArchive count_elements handler */
static int rararch_count_elements(handler_this_t *object, long *count TSRMLS_DC)
static int rararch_count_elements(zend_object *object, zend_long *count TSRMLS_DC)
{
rar_file_t *rar = NULL;
size_t entry_count;
@@ -555,10 +556,10 @@ static int rararch_count_elements(handler_this_t *object, long *count TSRMLS_DC)
}
entry_count = _rar_entry_count(rar);
if (entry_count > LONG_MAX)
entry_count = (size_t) LONG_MAX;
if (entry_count > ZEND_LONG_MAX)
entry_count = ZEND_LONG_MAX;
*count = (long) entry_count;
*count = (zend_long) entry_count;
return SUCCESS;
}
@@ -970,6 +971,13 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_rararchive_void, 0)
ZEND_END_ARG_INFO()
#if PHP_VERSION_ID >= 80200
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rararchive_tostring, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
#else
#define arginfo_rararchive_tostring arginfo_rararchive_void
#endif
/* }}} */
static zend_function_entry php_rararch_class_functions[] = {
@@ -984,7 +992,7 @@ static zend_function_entry php_rararch_class_functions[] = {
PHP_ME_MAPPING(isBroken, rar_broken_is, arginfo_rararchive_void, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(setAllowBroken, rar_allow_broken_set, arginfo_rararchive_setallowbroken, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(close, rar_close, arginfo_rararchive_void, ZEND_ACC_PUBLIC)
PHP_ME(rararch, __toString, arginfo_rararchive_void, ZEND_ACC_PUBLIC)
PHP_ME(rararch, __toString, arginfo_rararchive_tostring, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(__construct, rar_bogus_ctor, arginfo_rararchive_void, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR)
#if PHP_MAJOR_VERSION >= 8
PHP_ME(rararch, getIterator, arginfo_rararchive_getiterator, ZEND_ACC_PUBLIC)

View File

@@ -65,7 +65,11 @@ void _rar_entry_to_zval(zval *parent,
char *filename;
int filename_size,
filename_len;
#if PHP_MAJOR_VERSION >= 7
zend_long unp_size; /* zval stores PHP ints as zend_long, so use that here */
#else
long unp_size; /* zval stores PHP ints as long, so use that here */
#endif
zval *parent_copy = parent;
#if PHP_MAJOR_VERSION < 7
/* allocate zval on the heap */
@@ -85,7 +89,9 @@ void _rar_entry_to_zval(zval *parent,
zend_update_property(rar_class_entry_ptr, obj, "rarfile",
sizeof("rararch") - 1, parent_copy TSRMLS_CC);
#if ULONG_MAX > 0xffffffffUL
#if PHP_MAJOR_VERSION >= 7 && ZEND_ENABLE_ZVAL_LONG64
unp_size = ((zend_long) entry->UnpSize) + (((zend_long) entry->UnpSizeHigh) << 32);
#elif PHP_MAJOR_VERSION < 7 && ULONG_MAX > 0xffffffffUL
unp_size = ((long) entry->UnpSize) + (((long) entry->UnpSizeHigh) << 32);
#else
/* for 32-bit long, at least don't give negative values */
@@ -735,6 +741,13 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_rar_void, 0)
ZEND_END_ARG_INFO()
#if PHP_VERSION_ID >= 80200
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_rar_tostring, 0, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
#else
#define arginfo_rar_tostring arginfo_rar_void
#endif
/* }}} */
static zend_function_entry php_rar_class_functions[] = {
@@ -755,7 +768,7 @@ static zend_function_entry php_rar_class_functions[] = {
PHP_ME(rarentry, getRedirType, arginfo_rar_void, ZEND_ACC_PUBLIC)
PHP_ME(rarentry, isRedirectToDirectory, arginfo_rar_void, ZEND_ACC_PUBLIC)
PHP_ME(rarentry, getRedirTarget, arginfo_rar_void, ZEND_ACC_PUBLIC)
PHP_ME(rarentry, __toString, arginfo_rar_void, ZEND_ACC_PUBLIC)
PHP_ME(rarentry, __toString, arginfo_rar_tostring, ZEND_ACC_PUBLIC)
PHP_ME_MAPPING(__construct, rar_bogus_ctor, arginfo_rar_void, ZEND_ACC_PRIVATE | ZEND_ACC_CTOR)
{NULL, NULL, NULL}
};

View File

@@ -2829,10 +2829,10 @@ case "$1" in
gdb --args {$cmd}
;;
"valgrind")
USE_ZEND_ALLOC=0 valgrind $2 ${cmd}
USE_ZEND_ALLOC=0 valgrind $2 {$cmd}
;;
"rr")
rr record $2 ${cmd}
rr record $2 {$cmd}
;;
*)
{$cmd}

View File

@@ -163,5 +163,5 @@ array(2) {
Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d
Warning: rar_list() expects parameter 1 to be RarArchive, boo%s given in %s on line %d
Warning: rar_list() expects parameter 1 to be RarArchive, %s given in %s on line %d
Done

View File

@@ -91,5 +91,5 @@ object(RarEntry)#%d (%d) {
Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d
Warning: rar_entry_get() expects parameter 1 to be RarArchive, boo%s given in %s on line %d
Warning: rar_entry_get() expects parameter 1 to be RarArchive, %s given in %s on line %d
Done

View File

@@ -31,6 +31,6 @@ bool(false)
Warning: rar_open(): Failed to open %s: ERAR_EOPEN (file open error) in %s on line %d
Warning: rar_entry_get() expects parameter 1 to be RarArchive, boo%s given in %s on line %d
Warning: rar_entry_get() expects parameter 1 to be RarArchive, %s given in %s on line %d
Done

View File

@@ -9,10 +9,6 @@ $rar_file1 = rar_open(dirname(__FILE__).'/multi.part1.rar');
$entries = rar_list($rar_file1);
echo count($entries)." files:\n\n";
//var_dump($entries);
function int32_to_hex($value) {
$value &= 0xffffffff;
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
}
foreach ($entries as $e) {
$stream = $e->getStream();
if ($stream === false) {
@@ -25,7 +21,7 @@ foreach ($entries as $e) {
$a .= fread($stream, 8192);
}
echo strlen($a)." bytes, CRC ";
echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
}
echo "Done\n";

View File

@@ -9,10 +9,6 @@ $rar_file1 = rar_open(dirname(__FILE__).'/store_method.rar');
$entries = rar_list($rar_file1);
echo count($entries)." files:\n\n";
//var_dump($entries);
function int32_to_hex($value) {
$value &= 0xffffffff;
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
}
foreach ($entries as $e) {
$stream = $e->getStream();
echo $e->getName().": ";
@@ -21,7 +17,7 @@ foreach ($entries as $e) {
$a .= fread($stream, 512);
}
echo strlen($a)." bytes, CRC ";
echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
}
echo "Done\n";

View File

@@ -9,10 +9,6 @@ $rar_file1 = rar_open(dirname(__FILE__).'/solid.rar');
$entries = rar_list($rar_file1);
echo count($entries)." files:\n\n";
//var_dump($entries);
function int32_to_hex($value) {
$value &= 0xffffffff;
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
}
foreach ($entries as $e) {
$stream = $e->getStream();
echo $e->getName().": ";
@@ -21,7 +17,7 @@ foreach ($entries as $e) {
$a .= fread($stream, 8192);
}
echo strlen($a)." bytes, CRC ";
echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
}
echo "Done\n";

View File

@@ -4,6 +4,9 @@ RarArchive get iterator on closed file
<?php if(!extension_loaded("rar")) print "skip"; ?>
--FILE--
<?php
if (PHP_VERSION_ID>=80500){
ini_set('fatal_error_backtraces', 'Off');
}
$rarF = RarArchive::open(dirname(__FILE__) . '/latest_winrar.rar');
$rarF->close();
foreach ($rarF as $k => $rarE) {

View File

@@ -10,10 +10,6 @@ function resolve($vol) {
else
return null;
}
function int32_to_hex($value) {
$value &= 0xffffffff;
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
}
$rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar', null, 'resolve');
foreach ($rar_file1 as $e) {
$stream = $e->getStream();
@@ -23,7 +19,7 @@ foreach ($rar_file1 as $e) {
$a .= fread($stream, 8192);
}
echo strlen($a)." bytes, CRC ";
echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
}
echo "Done\n";

View File

@@ -10,10 +10,6 @@ function resolve($vol) {
else
return null;
}
function int32_to_hex($value) {
$value &= 0xffffffff;
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
}
echo "Fail:\n";
$rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar');
$entry = $rar_file1->getEntry('file2.txt');
@@ -22,7 +18,7 @@ echo "\nSuccess:\n";
$rar_file1 = rar_open(dirname(__FILE__).'/multi_broken.part1.rar', null, 'resolve');
$entry = $rar_file1->getEntry('file2.txt');
$entry->extract(null, dirname(__FILE__) . "/temp_file2.txt");
echo int32_to_hex(crc32(file_get_contents(dirname(__FILE__) . "/temp_file2.txt")));
echo strtoupper(hash("crc32b", file_get_contents(dirname(__FILE__) . "/temp_file2.txt")));
echo "\n";
echo "Done\n";
?>

View File

@@ -11,17 +11,13 @@ function resolve($vol) {
else
return null;
}
function int32_to_hex($value) {
$value &= 0xffffffff;
return str_pad(strtoupper(dechex($value)), 8, "0", STR_PAD_LEFT);
}
$stream = fopen("rar://" .
dirname(__FILE__) . '/multi_broken.part1.rar' .
"#file2.txt", "r", false,
stream_context_create(array('rar'=>array('volume_callback'=>'resolve'))));
$a = stream_get_contents($stream);
echo strlen($a)." bytes, CRC ";
echo int32_to_hex(crc32($a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
echo strtoupper(hash("crc32b", $a))."\n\n"; //you can confirm they're equal to those given by $e->getCrc()
echo "Done.\n";
--EXPECTF--
17704 bytes, CRC F2C79881

View File

@@ -7,6 +7,9 @@ if (key_exists('USE_ZEND_ALLOC', $_ENV) && PHP_VERSION_ID < 70000) die('skip do
?>
--FILE--
<?php
if (PHP_VERSION_ID>=80500){
ini_set('fatal_error_backtraces', 'Off');
}
$f1 = dirname(__FILE__) . "/latest_winrar.rar";
$a = RarArchive::open($f1);

View File

@@ -4,6 +4,9 @@ RarArchive read_property gives a fatal error on a write context
<?php if(!extension_loaded("rar")) print "skip"; ?>
--FILE--
<?php
if (PHP_VERSION_ID>=80500){
ini_set('fatal_error_backtraces', 'Off');
}
$f1 = dirname(__FILE__) . "/latest_winrar.rar";
$a = RarArchive::open($f1);

View File

@@ -7,6 +7,9 @@ if (key_exists('USE_ZEND_ALLOC', $_ENV) && PHP_VERSION_ID < 70000) die('skip do
?>
--FILE--
<?php
if (PHP_VERSION_ID>=80500){
ini_set('fatal_error_backtraces', 'Off');
}
$f1 = dirname(__FILE__) . "/latest_winrar.rar";
$a = RarArchive::open($f1);

View File

@@ -4,6 +4,9 @@ RarArchive unset_property gives a fatal error
<?php if(!extension_loaded("rar")) print "skip"; ?>
--FILE--
<?php
if (PHP_VERSION_ID>=80500){
ini_set('fatal_error_backtraces', 'Off');
}
$f1 = dirname(__FILE__) . "/latest_winrar.rar";
$a = RarArchive::open($f1);

View File

@@ -4,6 +4,9 @@ Traversal of RarArchive with foreach by reference gives error
<?php if(!extension_loaded("rar")) print "skip"; ?>
--FILE--
<?php
if (PHP_VERSION_ID>=80500){
ini_set('fatal_error_backtraces', 'Off');
}
$f1 = dirname(__FILE__) . "/latest_winrar.rar";
$a = RarArchive::open($f1);

View File

@@ -3,6 +3,7 @@ Supports version 5 RAR files
--SKIPIF--
<?php if(!extension_loaded("rar")) die("skip");
if (isset($_ENV['APPVEYOR'])) die("skip failing on appveyor");
if ($_ENV['RUNNER_OS'] === 'Windows') die("skip failing on Windows runner on GitHub Action");
--FILE--
<?php
RarException::setUsingExceptions(true);