PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » File Formats » Archive_Zip » Bug #6757

try to unpack files with some umlaut

Details

Submitted2006-02-12 10:42 UTC
Fromj dot mueller at department-x dot de
StatusSuspended
PackageArchive_Zip
PHP Version5.1.2
OSWinXP
Roadmaps(Not assigned)

Comments

[2006-02-12 10:42 UTC] j dot mueller at department-x dot de

Description:
------------
if i try to unpack zipfiles where filenames inside have some umlaut ...

Test script:
---------------
if (isset($_GET['do']) && 'upload' == $_GET['do'] && isset($_FILES['galleryzip'])) {

if (isset($_FILES['galleryzip']['name'])) {
$_FILES['galleryzip']['name'] = preg_replace("#([a-zA-Z0-9]+)#", "\\1", $_FILES['galleryzip']['name']);
}

if(move_uploaded_file($_FILES['galleryzip']['tmp_name'], ZIP.$_FILES['galleryzip']['name'])) {

$objZIP =& new Archive_Zip(ZIP.$_FILES['galleryzip']['name']);
$objZIP->extract(0);

$dirname = str_replace('.zip', '', $_FILES['galleryzip']['name']);
$objIMG->createThumb(ROOT.$dirname);

unlink(ZIP.$_FILES['galleryzip']['name']);

}
else {
trigger_error('verschieben der Datei fehlgeschlagen');
}

}

Expected result:
----------------
filenames with umlaut will not be create

now i have added 2 membervars in Archiv_zip
/**
* @var array search
*/
var $_search_array;

/**
* @var array replace
*/
var $_replace_array;

inside of the constructor

// ----- Set search and Replace Arrays
$this->_search_array = array(
"”","", "„","á", " "
);
$this->_replace_array = array(
"oe","ue", "ae", "ss", "_"
);

// in function _readCentralFileHeader after Get filename

$p_header['filename'] = str_replace($this->_search_array, $this->_replace_array, $p_header['filename']);

// in function _readFileHeader before Set the stored filename

$p_header['filename'] = str_replace($this->_search_array, $this->_replace_array, $p_header['filename']);

[2006-06-15 13:30 UTC] treeble at free dot fr

I have found some problems with accent and other caracter like that(ô, û, ï, ë ...)

I have corrected this problem with this two arrays :

$this->_search_array = array("Š", "‚", "ˆ", "‰", "‹", "Œ", "“", "”", "…", "–", " ");
$this->_replace_array = array("e", "e", "e", "e", "i" , "i", "o", "o", "a", "u", "_");

Sorry for my poor english

[2006-06-15 13:37 UTC] treeble at free dot fr

OK, ythe caracter can't be post correctly, so you just have to test with a filename with grave accent and other special caracter. You take the caracters who are posted (listContent() => print_r => filename), and you just have to put them in the search_array, and in the replace_array you have to give the equivalent caracter without dieresis, accent or circumflexe ...