forms: honor formaction / formmethod / formenctype on submit button#2279
Merged
karlseguin merged 1 commit intoApr 28, 2026
Merged
Conversation
When a form is submitted via a click on a submit button (or form.requestSubmit(button)), the HTML form-submission algorithm requires the submitter's formaction / formmethod / formenctype attributes to override the form's corresponding attributes when present. Frame.submitForm was reading action / method / enctype only from the form element, so the button-side overrides were silently ignored. The symmetrical lookup for formtarget already exists upstream — this commit applies the same pattern to the other three attributes. Closes lightpanda-io#2278
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a form is submitted via a click on a submit button (or
form.requestSubmit(button)), the submitter'sformaction/formmethod/formenctypeattributes are silently ignored — the form's own attributes always win. Per the HTML form-submission algorithm these per-submitter attributes must override the form's, and the symmetrical lookup already exists forformtarget. This PR adds the same submitter-first lookup for the other three.Closes #2278.
Root cause
Frame.submitForminsrc/browser/Frame.zigreadsaction,method, andenctypeonly from the form element. The submitter parameter (already plumbed through for thedisabledcheck,SubmitEvent.submitter, andFormData.init) is ignored in those three lookups.formtargetworks because that lookup is correct (lines 3684-3691 onmain).flowchart LR A[click submit button] --> B[Frame.submitForm] B --> C[action = form.action] B --> D[method = form.method] B --> E[enctype = form.enctype] C --> F[wrong URL] D --> F E --> F style C fill:#fdd style D fill:#fdd style E fill:#fdd style F fill:#fddFix
src/browser/Frame.zig—submitForm: wrap theenctype/method/actionlookups in submitter-first blocks, falling back to the form's attribute when the submitter has none. Mirrors the existingformtargetblock.flowchart LR A[click submit button] --> B[Frame.submitForm] B --> C[action = submitter.formaction OR form.action] B --> D[method = submitter.formmethod OR form.method] B --> E[enctype = submitter.formenctype OR form.enctype] C --> F[correct URL] D --> F E --> F style C fill:#dfd style D fill:#dfd style E fill:#dfd style F fill:#dfdTest
src/browser/tests/frames/target.htmladds three new fixtures next to the existingformtargettest:formaction— form actionsupport/should-not-load.html, buttonformaction="support/page.html"→ iframe loadspage.htmlformmethod— form methodGETactionsupport/page.html, inputname=x value=probe, buttonformmethod="POST"→ iframe URL has no query string (POST sent the FormData in the body, not appended to the URL)formaction_and_formmethod— both overrides on the same submitterTEST_FILTER='WebApi: Frames#target' mise exec -- zig build test $V8passes with the fix, fails onmain.repro.sh(HTML fixture + Python static server + Node CDP driver via rawws) is documented in forms: formaction / formmethod / formenctype on submit button are ignored #2278. Exits 1 onmain(3 of 4 cases FAIL), exits 0 with this commit (all 4 PASS) when run against a local debug build of this branch.Notes
formAction/formMethod/formEnctypeare not exposed onHTMLButtonElement/HTMLInputElementupstream yet — thegetAttribute('formaction')/ etc. content-attribute path used here works regardless. Adding the IDL accessors is independent and out of scope for this PR.isSubmitButton(submitter)— the existingformtargetlookup at lines 3684-3691 doesn't gate either, and a non-button submitter (e.g. an<input type=text>after Enter) won't have these attributes set on it in well-formed HTML, so thegetAttributeSafereturnsnulland the form's attribute is used. Matches precedent.