Bug #72200 [Fbk->Opn]: ZipArchive::open() creates invalidly encoded filenames

From: Date: Tue, 17 May 2016 12:41:06 +0000
Subject: Bug #72200 [Fbk->Opn]: ZipArchive::open() creates invalidly encoded filenames
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201156@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72200&edit=1

 ID:                 72200
 User updated by:    thomas dot kuhn dot berlin at gmail dot com
 Reported by:        thomas dot kuhn dot berlin at gmail dot com
 Summary:            ZipArchive::open() creates invalidly encoded
                     filenames
-Status:             Feedback
+Status:             Open
 Type:               Bug
 Package:            Zip Related
 Operating System:   Windows Server 2012 R2 & Win7
 PHP Version:        7.0.6
 Block user comment: N
 Private report:     N

 New Comment:

@cmb: you missed the point: When filenames contain !!non-us-ascii-letters!! like !!öäü!! or
!!asian chars!! etc., ZipArchive creates filenames in a way that those files are not accessible via
PHP because the encoding is wrong. 

and btw !!adding!! files to an archive containing such letters in their filename fails as well. i
have to copy them to to tmp-files first :(


Previous Comments:
------------------------------------------------------------------------
[2016-05-17 12:32:10] cmb@php.net

Using the following slightly modified script, I can't reproduce
the issue with PHP 7.0.6 (VC14 x86 Non Thread Safe (2016-Apr-29
00:38:17)) on Windows 10:

    <?php
    
    $filename = "m\xc3\xbcller";
    $zip = new ZipArchive;
    var_dump($zip->open($filename,
            ZipArchive::CREATE|ZipArchive::OVERWRITE));
    var_dump($zip->addFromString('foo', 'bar'));
    var_dump($zip->close());
    var_dump(file_exists($filename));
    
Output

    bool(true)
    bool(true)
    bool(true)
    bool(true)

What results do you get running this script?

------------------------------------------------------------------------
[2016-05-11 16:30:25] thomas dot kuhn dot berlin at gmail dot com

Description:
------------
New in PHP7 on Windows: When filenames contain non-us-ascii-letters like öäü or asian chars
etc., ZipArchive creates filenames in a way that those files are not accessible via PHP because the
encoding is wrong.

testscript output PHP 5.5.35:
	php default_charset: UTF-8
	bool(true)

testscript output PHP 7.0.6:
	php default_charset: UTF-8
	bool(false)

run on Windows Server 2012 R2 and Windows7


Test script:
---------------
print "php default_charset: ".ini_get('default_charset')."\n"; // just
4 info (UTF-8)

$filename = "bugtest_müller-lüdenscheid.zip"; // just an example
$filename = utf8_encode($filename);	// simulating my database delivering utf8-string

$zip = new ZipArchive();
if( $zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true )
{
	$zip->addFile('bugtest.php', 'bugtest.php'); // copy of script file itself
	$zip->close();
}

var_dump( is_file($filename) );  // delivers ?






------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72200&edit=1


Thread (8 messages)

« previous php.bugs (#201156) next »