Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can acceptedName distinguish between foldername and filename? #1959

Closed
donShakespeare opened this issue Apr 10, 2017 · 7 comments
Closed

Can acceptedName distinguish between foldername and filename? #1959

donShakespeare opened this issue Apr 10, 2017 · 7 comments
Assignees
Labels

Comments

@donShakespeare
Copy link

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.

@nao-pon nao-pon self-assigned this Apr 11, 2017
@nao-pon
Copy link
Member

nao-pon commented Apr 11, 2017

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

Thanks! 👍

@nao-pon
Copy link
Member

nao-pon commented Apr 11, 2017

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

Thanks!

@donShakespeare
Copy link
Author

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);
  }
}

@nao-pon
Copy link
Member

nao-pon commented Apr 12, 2017

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.

nao-pon added a commit that referenced this issue Apr 12, 2017
For to make configurable to characters allowed in path name.

c.f. #1959
@nao-pon
Copy link
Member

nao-pon commented Apr 12, 2017

Done it. Thanks!

@donShakespeare
Copy link
Author

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

@nao-pon
Copy link
Member

nao-pon commented Apr 21, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants