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

(#396) Fixed unwated behaviour of files and filesOpts while not uploading file. #397

Closed
wants to merge 2 commits into from

Conversation

tusharad
Copy link
Contributor

Please visit issue #396 for more details.

Issue

When using files or filesOpts function, upon not uploading any file, these function would still return a list of tuples containing filename as "\"\"" and fileContent as "\"\"".

Solution

  • I added a filter function right after the parseRequestBodyExBS which converts the body into the list of FileInfo type, that will remove any file whose filename is "\"\"".
  • I added the entry in changelog.md under breaking changes as well.

Thanks.

Copy link
Collaborator

@ocramz ocramz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add tests ?

let
fs' = filter emptyFile fs
return (convertBoth <$> formparams, convertKey <$> fs')
where emptyFile (_,fInfo) = ("\"\"" /= (W.fileName fInfo))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do HTML forms behave if the name attribute is absent? i.e. how does the payload sent by the browser look like.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ocramz,
I will add the test-cases.

payload when I upload style.css file with name attribute in HTML.
Screenshot from 2024-04-30 12-10-21

Payload when I upload style.css file without name attribute in HTML.
image

@tusharad
Copy link
Contributor Author

@ocramz, I have added the test-cases.

@ocramz
Copy link
Collaborator

ocramz commented May 2, 2024

@tusharad since this change would break users of many versions of scotty (for good or worse: users will rely on every observable feature of a software), maybe it's a good idea to review how other web frameworks behave with empty files input.

@tusharad tusharad closed this Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants