File tree Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Expand file tree Collapse file tree 3 files changed +22
-10
lines changed Original file line number Diff line number Diff line change @@ -46,11 +46,9 @@ public function upload()
4646 $ response = count ($ error_bag ) > 0 ? $ error_bag : parent ::$ success_response ;
4747 } else { // upload via ckeditor5 expects json responses
4848 if (is_null ($ new_filename )) {
49- $ response = ['error ' =>
50- [
51- 'message ' => $ error_bag [0 ]
52- ]
53- ];
49+ $ response = [
50+ 'error ' => [ 'message ' => $ error_bag [0 ] ]
51+ ];
5452 } else {
5553 $ url = $ this ->lfm ->setName ($ new_filename )->url ();
5654
Original file line number Diff line number Diff line change @@ -46,8 +46,22 @@ public function config($key)
4646 */
4747 public function getNameFromPath ($ path )
4848 {
49- setlocale (LC_ALL , 'en_US.UTF-8 ' );
50- return pathinfo ($ path , PATHINFO_BASENAME );
49+ return $ this ->utf8Pathinfo ($ path , 'basename ' );
50+ }
51+
52+ public function utf8Pathinfo ($ path , $ part_name )
53+ {
54+ // XXX: all locale work-around for issue: utf8 file name got emptified
55+ // if there's no '/', we're probably dealing with just a filename
56+ // so just put an 'a' in front of it
57+ if (strpos ($ path , '/ ' ) === false ) {
58+ $ path_parts = pathinfo ('a ' . $ path );
59+ } else {
60+ $ path = str_replace ('/ ' , '/a ' , $ path );
61+ $ path_parts = pathinfo ($ path );
62+ }
63+
64+ return substr ($ path_parts [$ part_name ], 1 );
5165 }
5266
5367 public function allowFolderType ($ type )
Original file line number Diff line number Diff line change @@ -277,9 +277,9 @@ private function uploadValidator($file)
277277
278278 private function getNewName ($ file )
279279 {
280- setlocale ( LC_ALL , ' en_US.UTF-8 ' );
281- $ new_file_name = $ this ->helper
282- -> translateFromUtf8 ( trim ( pathinfo ( $ file -> getClientOriginalName (), PATHINFO_FILENAME )) );
280+ $ new_file_name = $ this -> helper -> translateFromUtf8 (
281+ trim ( $ this ->helper -> utf8Pathinfo ( $ file -> getClientOriginalName (), " filename " ))
282+ );
283283
284284 $ extension = $ file ->getClientOriginalExtension ();
285285
You can’t perform that action at this time.
0 commit comments