|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2019-01-24 16:10 UTC] offluri at gmail dot com
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 ?

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:
(In Windows with "Différence.ods" LibreOffice calc file AND default_charset = "Windows-1252" in php.ini)

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-01-25 11:20 UTC]
-Status: Open +Status: Feedback
 [2019-01-25 11:20 UTC]
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.

 [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-2021 The PHP Group
All rights reserved.
Last updated: Thu Jun 17 16:01:24 2021 UTC