This is a migrated thread and some comments may be shown as answers.

[Solved] EditorFileBrowserController IsValidFile bug

0 Answers 100 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
cheburek
Top achievements
Rank 1
cheburek asked on 03 Aug 2011, 12:19 PM
Hello!
I tried to submit a bug to the issue tracker but seems that it is not allowed to submit issues for my account so I write here

Telerik MVC 2011 Q2
EditorFileBrowserController

property Filter default value is "*.png,*.gif,*.jpg,*.jpeg"
In inherited class Filter is overriden and has value "*" to allow uploading for all types of files.
But private method IsValidFile does not allow to use "*" - it requires enumatation if all allowed extensions explicitely defined.

But it is not obvious - I had to dig into source code and investigate why I cannot submit any file with "Forbidden" exception (from Upload method).
if (!this.AuthorizeUpload(path, file))
        throw new HttpException(403, "Forbidden");


Following fix should allow using * symbol to specify all kinds of files
private bool IsValidFile(string fileName)
       {
            string extension = Path.GetExtension(fileName);
            return Filter=="*" || Enumerable.Any(Filter.Split(new[]
                {
                  ','
                }), e => e.EndsWith(extension, StringComparison.InvariantCultureIgnoreCase));
       }

Thanks
Tags
Editor
Asked by
cheburek
Top achievements
Rank 1
Share this question
or