Bug in the plugin related to file names
-
Hello,
I’ve found a bug in the plugin related to file names.
For example, if a file contains Cyrillic characters, they will be ignored.
For instance:"вал?за.jpg" => ".jpg" (This leads to the error "file name or extension is missing" because in this case, the function cannot find the name in the string.)
"чорна-вал?за.jpg" => "-вал?за.jpg" (When you try to change the file name and save the new name, you get the error "The media containing directory is not writable!" because the plugin cannot find a file with such a name, probably because it doesn't exist.)
"black-вал?за.jpg" => "black-вал?за.jpg" (In this case, the plugin works correctly.)The reason for this issue is the PHP function “basename.” The problem arises because it depends on “setlocale,” and if the “locale” is not explicitly defined on the server, it will work incorrectly.
As far as I can see, the “basename” function is only used in the “classes/class-lib.php” file in your plugin’s code.
The simplest way to fix the bug is to add this method:public static function basename_safe($path) {
$path = rtrim($path, '/');
$path = explode('/', $path);
return end($path);
}And then replace basename() with self::basename_safe().
If possible, please apply this change to the plugin and upload a new version of it.
- The topic ‘Bug in the plugin related to file names’ is closed to new replies.