[solved] Wrong upload (files to be sold) for cyrillic filenames (VM 1.1.9,UTF-8)

Started by i3laze, March 06, 2012, 12:44:00 PM

Previous topic - Next topic

i3laze

When I upload a file "to be sold", the cyrillic name like 'кир123abc.jpg' is shrinked and uploaded as '123abc.jpg' (in VM database).
The uploaded filename on FTP-server is still 'кир123abc.jpg'.

mysql & website is in UTF-8, VM 1.1.9.

The generated Download Code leads to "file not found".
That should be fixed.

Can pay 20+$ via PayPal.

i3laze

Solved. Almost by myself.

1. File upload. File's title is retrieved from upload URL by basename() function, which depends on codepage.
reported bug: http://brokenbrake.biz/2009/05/22/php-utf-8
Quote# Alek$:
Самый неочивидный глюк PHP, с которым я имел дело выглядит так:
$file_basename = basename('Русское имя файла из нескольких слов.zip');
Хз, почему, но в $file_basename оказивается не «Русское имя файла из нескольких слов.zip», как следовало бы ожидать, а «имя файла из нескольких слов.zip».
The solution is to force codepage in header of administrator\components\com_virtuemart\classes\ps_product_files.php:
<?php setlocale(LC_ALL'en_US.UTF8');

2. File downloads. Same:
administrator\components\com_virtuemart\classes\ps_order.php:
<?php setlocale(LC_ALL'en_US.UTF8');
+  the download is given back with UTF8 title -  only Google Chrome guesses to convert the title correctly,  other browsers, like IE, will download file as is:
' Единая Касса СЃ С,,СЂРѕРґРѕРј_РїСѓСЃС,РѕР№.doc'
The idea is to fix vmConnector::sendFile with iconv():
vmConnector::sendFile( $datei, $mime_type, iconv("UTF-8", "cp1251", basename($file_name)) );

Welcome :)