Commit 240ed976 authored by zulljin's avatar zulljin
Browse files

Issue #2886549 by ufku: File name validation

parent 6f12e420
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -47,10 +47,8 @@ class Rename extends ImcePluginBase {

    // Check type.
    if ($old_file->type == 'file') {
      // Delete dots and space at the beginning/end name.
      $new_name = trim($fm->getPost('new_name'), "\x00..\x1F.");
      // Crop string up to 50 characters.
      $new_name = mb_substr($new_name,0,50);
      $new_name = mb_substr($fm->getPost('new_name'),0,50);
      // Delete special symbols.
      $new_name = preg_replace('/[^\w_-]+/u', '', $new_name);
      $new_name = $new_name . '.' . pathinfo($old_name, PATHINFO_EXTENSION);