1 haharen Dec 28, 2015 14:56
3 mgsolipa Dec 29, 2015 10:11
@haharen I'm not able to reproduce any of the issues but the number 5, which is produced due to b2evolution replaces any character which is not in this group: [^a-z0-9-.], with an underscore ( ).
I guess the problem on my side is that my SO is not in Chinese, so I get a "not valid file/folder name" errors when I try steps 1-2-3 and 6.
Maybe you can try commenting line ~540 on inc/files/model/_file.funcs.php
$filename = preg_replace( '/[^a-z0-9\-_.]+/i', '_', $filename );
but I don't know if that can produce an unexpected behaviour in your site.
4 haharen Dec 29, 2015 11:50
@mgsolipa Thank you very much!
I comment the line, and the 'drag & drop upload' worked correctly,
Also the names of all uploaded files on the server are right! ( I user the Debian as systemserver, apache as webserver, chrome as web browser)
Only on the back-office, the file manager appearence get the displaying errors.
Thanks,
haharen
5 haharen Jan 01, 2016 08:58
Now I am glad to say I found the reason of these issues and have solved all of them.
First, I got the version 5.6 of php worked on Debian can't deal well with the basename() function for Chinese characters. For example :
echo basename("opt/mydoc/好好学习.doc");
which I expected to print"好好学习.doc"
, but the result is“.doc”
. The Chinese character dispeared. So I try to find the solution but nothing except of writing another function instead of it. So the function is like this:function get_basename($filename){ return preg_replace('/^.+[\\\\\\/]/', '', $filename); }
then replace all the basename() function in all of the code files. Of course, it's not a good way, also maybe another version of php have no such problem.
Drag & drop upload may produce some messy code when you use Chinese local files
When you upload some files, maybe you will get some errors ,for example the validation of filename. You may see the error message is" «è±è¯å级åå¹´é«é¢è¯æ±(带é³æ ) (1) (1).docx» is not a valid filename."
but the true one should be"英语四级历年高频词汇(带音标) (1) (1).docx» is not a valid filename."
The reason of this issue is that the javascript can't base64_decode the Chinese Characters. I used the following method:
1). Atquick_upload.php
about 160 lines , add the code:function phpescape($string, $in_encoding = 'UTF-8',$out_encoding = 'UCS-2') { $return = ''; if (function_exists('mb_get_info')) { for($x = 0; $x < mb_strlen ( $string, $in_encoding ); $x ++) { $str = mb_substr ( $string, $x, 1, $in_encoding ); if (strlen ( $str ) > 1) { // 多字节字符 $return .= '%u' . strtoupper ( bin2hex ( mb_convert_encoding ( $str, $out_encoding, $in_encoding ) ) ); } else { $return .= '%' . strtoupper ( bin2hex ( $str ) ); } } } return $return; }
then in
out_echo()
function, add$message['text'] = phpescape($message['text']);
before
$message['text'] = base64_encode($message['text']);
2). At _file_funcs.php
2320 lines, add unescape() before base64_decode() in the javascript codes, so it's like this at last
var text = unescape(base64_decode( responseJSON.success.text ));
6 mgsolipa Jan 09, 2016 11:01
@haharen thanks for reporting and offering solutions. The dev team is now informed about this issue.
Regards!
The file name is : 英语四级历年高频词汇(带音标).docx
The category name is : 英语