Elfinder: Can acceptedName distinguish between foldername and filename?

Created on 11 Apr 2017  路  7Comments  路  Source: Studio-42/elFinder

In conjunction with mimeTypes, for added security, I have a function that forces acceptedName to not start with dot, and to force an extension that is predefined in an array.

Folders don't have extension, therefore this function will prevent folders from being created or renamed. This is undesirable.
Anybody have ideas?
Thanks.

feature

All 7 comments

@donShakespeare OK. I'll make a new configuration option acceptedDirname to control the directory name.

Thanks! 馃憤

Done. @donShakespeare you can use acceptedDirname in volume roots options with nightly build or elFinder >= 2.1.24.

Thanks!

Excellent! Thank you. Makes a world of difference now.

  1. Will this remain as acceptedDirname or acceptedDirName

  2. Will there be corresponding changes in the JS ui to return Invalid folder name instead of Invalid file name?

  3. Will the wonderful Sanitizer Plugin also have this feature?

private function sanitizeFolderName($filename, $opts, $allows = array()) {
  $targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
  return str_replace($targets, $opts['replace'], $filename);
}

or at atleast

private function sanitizeFileName($filename, $origin, $opts, $allows = array()) {
  if($origin != "folder"){
    $targets = $allows? array_diff($opts['targets'], $allows) : $opts['targets'];
    return str_replace($targets, $opts['replace'], $filename);
  }
}

Thanks for the suggestion!

Will this remain as acceptedDirname or acceptedDirName

Yes, It is determined as acceptedDirname.

Will there be corresponding changes in the JS ui to return Invalid folder name instead of Invalid file name?

Yes, I'll implement it.

Will the wonderful Sanitizer Plugin also have this feature?

Yes, I'll add an option pathAllows for to make configurable to characters allowed in path name.

Done it. Thanks!

Works beautifully!

I noticed this code errInvDirame not translating; is that something that will be fixed when the release is made? (Invalid folder name)
```
Unable to rename "myFolder".
errInvDirame

I noticed this code errInvDirame not translating; is that something that will be fixed when the release is made? (Invalid folder name)

Yes, it will be included in 2.1.24. Until then you can try it with the nightly build. When you try, do not forget to clear the browser cache.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shiyee picture shiyee  路  3Comments

ashickurnoor picture ashickurnoor  路  4Comments

golee picture golee  路  3Comments

mschlosser22 picture mschlosser22  路  4Comments

CodeLyokoXtEAM picture CodeLyokoXtEAM  路  3Comments