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

fix formdata arg validation #3529

Merged
merged 1 commit into from
Sep 1, 2024
Merged

Conversation

KhafraDev
Copy link
Member

var fd = new FormData()

fd.set('key', new Blob([]), undefined)
fd.get('key').name // should be 'blob'

fd.append('key1', new Blob([]), undefined)
fd.get('key1').name // should be 'blob'

I painfully found out that the wpts are not extensive

@KhafraDev KhafraDev requested a review from Uzlopak August 31, 2024 17:54
Comment on lines +124 to +133
name = webidl.converters.USVString(name)

if (arguments.length === 3 || value instanceof Blob) {
value = webidl.converters.Blob(value, prefix, 'value')

if (filename !== undefined) {
filename = webidl.converters.USVString(filename)
}
} else {
value = webidl.converters.USVString(value)
Copy link
Contributor

Choose a reason for hiding this comment

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

cant this be at line 140?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. The webidl stuff occurs before the steps, but the step is also not needed because js doesn't have method overrides (hence the weird webidl here).

The set(name, value) and set(name, blobValue, filename) method steps are:

The first step is telling us to set value to "blobValue" if there were 3 arguments passed, otherwise do nothing. "value" is only ever "value" here.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@KhafraDev KhafraDev merged commit e071406 into nodejs:main Sep 1, 2024
32 checks passed
@KhafraDev KhafraDev deleted the fix-formdata branch September 1, 2024 14:59
Copy link
Contributor

github-actions bot commented Oct 6, 2024

The backport to v6.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-v6.x v6.x
# Navigate to the new working tree
cd .worktrees/backport-v6.x
# Create a new branch
git switch --create backport-3529-to-v6.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 e0714063deb24f4887b00e0b90060ac71190b273
# Push it to GitHub
git push --set-upstream origin backport-3529-to-v6.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-v6.x

Then, create a pull request where the base branch is v6.x and the compare/head branch is backport-3529-to-v6.x.

@Uzlopak
Copy link
Contributor

Uzlopak commented Oct 6, 2024

@KhafraDev
I think this is worth to get backported

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

Successfully merging this pull request may close these issues.

3 participants