php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75557 Error opening archive w/non-english chars in path
Submitted: 2017-11-23 07:28 UTC Modified: -
From: piven dot m at gmail dot com Assigned:
Status: Open Package: rar (PECL)
PHP Version: 7.1.11 OS: Windows (7, Srv2008)
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2017-11-23 07:28 UTC] piven dot m at gmail dot com
Description:
------------
Attempt to open archive with non-english (cyrilic) characters in the path results a read error:

Warning: RarArchive::open(): Failed to open C:\php\папка\test.rar: ERAR_EOPEN (file open error) in C:\php\testrar.php on line 2

My attempt to replace the char* with zend_string* was unsuccessful in function PHP_FUNCTION(rar_open).

Test script:
---------------
This scripts get same errors:
<?php
// In this script i'm try to open archive, called "тест.rar" from folder "папка" (Russian Cyrilic, UTF-8 filepath in php7.1)
$rar = RarArchive::open(__DIR__ .'/папка/тест.rar');
// In this moment i get "ERAR_EOPEN (file open error)" warning
if(false !== $rar) {
	print_r($rar->getEntries());
	$rar->close();
}
?>

Ok. Let's try to recode path from UTF-8 to WINDOWS-1251:
<?php
// Recode by iconv
$rar = RarArchive::open(iconv('UTF-8','WINDOWS-1251',__DIR__ .'/папка/тест.rar'));
// But still have same "ERAR_EOPEN (file open error)" warning
if(false !== $rar) {
	print_r($rar->getEntries());
	$rar->close();
}
?>

Expected result:
----------------
Array
(
    [0] => RarEntry Object
        (
            [rarfile:RarEntry:private] => RarArchive Object
                (
                )

            [position:RarEntry:private] => 0
            [name:RarEntry:private] => php.exe
            [unpacked_size:RarEntry:private] => 127488
            [packed_size:RarEntry:private] => 45642
            [host_os:RarEntry:private] => 2
            [file_time:RarEntry:private] => 2017-11-23 09:56:08
            [crc:RarEntry:private] => 23791171
            [attr:RarEntry:private] => 32
            [version:RarEntry:private] => 29
            [method:RarEntry:private] => 53
            [flags:RarEntry:private] => 0
            [redir_type:RarEntry:private] => 0
            [redir_to_directory:RarEntry:private] =>
            [redir_target:RarEntry:private] =>
        )

    [1] => RarEntry Object
        (
            [rarfile:RarEntry:private] => RarArchive Object
                (
                )

            [position:RarEntry:private] => 1
            [name:RarEntry:private] => тест.rar
            [unpacked_size:RarEntry:private] => 15645
            [packed_size:RarEntry:private] => 15645
            [host_os:RarEntry:private] => 2
            [file_time:RarEntry:private] => 2017-11-23 09:29:38
            [crc:RarEntry:private] => e5f65ba2
            [attr:RarEntry:private] => 32
            [version:RarEntry:private] => 29
            [method:RarEntry:private] => 48
            [flags:RarEntry:private] => 0
            [redir_type:RarEntry:private] => 0
            [redir_to_directory:RarEntry:private] =>
            [redir_target:RarEntry:private] =>
        )

)


Actual result:
--------------
Warning: RarArchive::open(): Failed to open C:\php\папка\test.rar: ERAR_EOPEN (file open error) in C:\php\testrar.php on line 2

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Wed Dec 11 22:01:24 2019 UTC