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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
27 + 21 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sun Jun 16 16:01:28 2024 UTC