Files List in Admin panel wont show non-english filenames

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
I have a whole bunch of files that i believe are in Chinese. In the admin panel, if i go to Manage Files, the filename column wont show anything if it is non-english. The filename for example is "良_.中英字幕-人人影_.JPG".
Assuming this is blocked for security reasons or is it a bug ?
2018-02-26_15-30-46.png
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
Couple of questions:

- If you click 'edit' in the admin area do they show ok?
- Do they show ok in the users file manager? (impersonate user)

There is filtering for security on the filename, although it should allow any utf8 characters after striping html tags.
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
yes the file names show OK when i click Edit and they also show fine when i impersonate. Just not in 'Manage Files' in admin panel.
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
I've tested with the above filename on our local dev and fhscript.com demo site, both should the characters in the admin area fine. Are you on an older version? Can you reproduce it on our demo site?
 

sukhman21

Member
YetiShare User
YetiShare Supporter
Jan 26, 2015
508
3
18
same thing happening on demo server fhscript.com , i uploaded a MP4 file (Date uploaded:04/03/2018, filesize: 8 MB)
 

adam

Administrator
Staff member
Dec 5, 2009
2,046
108
63
Thanks for the additional info. The issue was caused by limitStringLength() within "\admin\_admin_functions.inc.php". It calls the standard PHP function substr() which seems to have issues with certain character sets. To resolve it replace the whole function with the following:
PHP:
public static function limitStringLength($string, $length = 100) {
        // don't add the ... if the string length is already less than $length
        if (strlen($string) < $length) {
            return $string;
        }

        // safer string limiting
        if (function_exists('mb_substr')) {
            return mb_substr($string, 0, $length, "utf-8") . '...';
        }

        // fallback
        return substr($string, 0, $length) . '...';
    }
This will be part of the next release.