php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77516 ZipArchive::open not use default_charset setting
Submitted: 2019-01-24 16:10 UTC Modified: 2019-02-03 04:22 UTC
From: offluri at gmail dot com Assigned:
Status: No Feedback Package: Zip Related
PHP Version: 7.2.14 OS: Windows 7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: offluri at gmail dot com
New email:
PHP Version: OS:

 

 [2019-01-24 16:10 UTC] offluri at gmail dot com
Description:
------------
Hello,
I'm working in windows (french) on a console php script with Windows-1252 charset.
I'm change default_charset seting in php.ini : 
default_charset = "Windows-1252"

My script convert a .ods file in a .sql script with using phpspreadsheet lib.

I'm use a batch file to launch my php script. This allow drag-and-drop file over .bat to launch conversion.

Problem : This not work with filename countain accentuated char. Problem is in ZipArchive::Open(). Filename must be encoded with UTF-8 charset to work. 

Before open file, phpspreadsheet verify if file exist and readable with use is_file() and is_readable(). In this function, filename must be encoded with default_charset setting.

So i have a problem : If I translate filename to UTF-8, it's not work (is_file() block) but when i left CP1252 charset, ZipArchive::Open() not work.

This is inconsistent. Can you modify ZipArchive::Open()for this function use default_charset setting for filename parameters ?
Ty


Test script:
---------------
// For just test ZipArchive :
$zip = new ZipArchive();
$res = $zip->open("Différence.ods");
if ($res!== true) {
  echo 'FAIL';
} else {
  echo 'OK';
}

Expected result:
----------------
OK
(In Windows with "Différence.ods" LibreOffice calc file AND default_charset = "Windows-1252" in php.ini)

Actual result:
--------------
FAIL
(In Windows with "Différence.ods" LibreOffice calc file AND default_charset = "Windows-1252" in php.ini)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-25 11:20 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2019-01-25 11:20 UTC] ab@php.net
Thanks for the report. Please be sure your script with the hardcoded filename is UTF-8 encoded as well. ZipArchive::open() is just fine with UTF-8 filenames, ANSI filenames are supported too.

Also, you mention is_file() all the time, but there's no occurrence in the repro code. What exactly is the issue with is_file()?

In general, using UTF-8 everywhere should solve your issue.

Thanks.
 [2019-02-03 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jul 13 06:01:26 2020 UTC