0

I am tryign to save a filename to a proeprty and send back to the server. My only option so far is to use [AllowHtml] or [ValidateInput(false)], which works but I'm looking for something more specific.

Is there a data attribute that allows file names/paths, but not HTML in general?

If there is not, how can I write logic so that I can call the following when it's evaluating/binding?

bool validate(string s)
{
    if (isValidFileName()) //this part I think I can write
    {
       return isDangerousRequest(); //what function do I call??
    }
}
TruthOf42
  • 2,017
  • 4
  • 23
  • 38
  • Maybe you can check this one: https://stackoverflow.com/questions/62771/how-do-i-check-if-a-given-string-is-a-legal-valid-file-name-under-windows/62888 – Willy David Jr Sep 12 '18 at 15:55
  • Why do you file names include html characters that require you to use `[AllowHtml]`? And what characters are the problem? –  Sep 12 '18 at 21:37
  • The specific Characters are "!@#$^()_-=;'[]{},.~`()" which are all valid filename chars, but using AllowHtml allows them to pass through as well – TruthOf42 Sep 13 '18 at 14:39
  • You could always apply a `[ReqularExpression]` attribute that allows only valid file name characters –  Sep 13 '18 at 23:21

0 Answers0