Skip to main content
September 11, 2023
Question

How to validate/handle file upload for filename contain double extension?

  • September 11, 2023
  • 10 replies
  • 0 views

Hi All,

We have observation from our VA testing team, that while uploading file it should not contain double extension like as shown below:

FileUploadBypass.php%00.xlsx

Currently Appian is allowing to upload the file in to application because of extension .xlsx but VA testing team suggested us to file name should not contain double extension.

Any suggestions on this, how to validate this kind of observation?

Regards,
Sandeep

    10 replies

    stewart.burchell
    September 11, 2023

    A file as you describe will have two period characters in its filename so you can simply validate that the filename can only have one period character in it.

    September 11, 2023

    Thank you Stewart Burchell,

    Could you please suggest some sample validation code, so that i may try to check once.

    Regards,
    Sandeep

    stefanhelzle0001
    Brainy
    September 11, 2023

    len(cleanwith("FileUploadBypass.php%00.xlsx", ".")) > 1

    mathieud0001
    Brainy
    September 11, 2023

    I asked ChatGPT to create a Regex. Haven't had time to extensively test it but it's a starting point.

    a!localVariables(
      local!pattern: "^(?=.*\.[^.]+)(?!(?:.*\.[^.]+){2}).*$",
      regexmatch(
        local!pattern,
        "FileUploadBypass.php%00.xlsx"
      )
    )
    

    September 13, 2023

    Thank you Mathieu Drouin,
    On UI at a!fileUploadField() we have put the given validation.

    Regards,
    Sandeep