Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
fc44f83
docs: plan the Phase 12 test split and characterization sweep, and de…
kevindb Nov 1, 2026
8164d6c
test: split test/test.js into one file per area under test/suite
kevindb Nov 1, 2026
0b240ff
test: characterize serialization
kevindb Nov 1, 2026
b0445d8
test: characterize field helpers
kevindb Nov 1, 2026
b9cd917
test: stop pinning debug log text
kevindb Nov 1, 2026
e0112dc
test: characterize ajaxSubmit preparation
kevindb Nov 1, 2026
f0ba39e
test: characterize the XHR transports
kevindb Nov 1, 2026
b21099b
test: characterize the iframe transport
kevindb Nov 1, 2026
b0f1343
test: keep triggered clicks in ajaxForm tests from submitting
kevindb Nov 1, 2026
1be21d4
test: characterize ajaxForm binding
kevindb Nov 1, 2026
1cb626d
test: pin the iframeTarget name and image-only form bugs
kevindb Nov 1, 2026
e642c28
build: insert 'use strict' after the UMD header in the classic build
kevindb Nov 1, 2026
2de6799
refactor: read and write form members through one module
kevindb Nov 1, 2026
1f2af61
fix: read form members a same-named control cannot hide
kevindb Nov 1, 2026
08ca10c
fix: restore the form's attributes after an iframe upload
kevindb Nov 1, 2026
5e58181
fix: reset forms whose controls are named like form members
kevindb Nov 1, 2026
e6d1f4c
docs: record the form members changes
kevindb Nov 1, 2026
62ada42
fix: settle iframe uploads whose frame is not in the document with an…
kevindb Nov 1, 2026
62f9770
refactor: share argument normalization and debug logging as modules
kevindb Nov 1, 2026
730a670
refactor: prepare, deliver and route submissions in their own module
kevindb Nov 1, 2026
af3a71e
refactor: move the FormData and plain ajax transports to their own mo…
kevindb Nov 1, 2026
acb56fb
refactor: move the iframe transport to its own module as is
kevindb Nov 1, 2026
68162c8
docs: record the Submission refactor metrics
kevindb Nov 1, 2026
61eedee
ci: follow target callbacks through helper functions in the CodeQL qu…
kevindb Nov 1, 2026
d922d9a
fix: submit to the form action when the url is false or empty
kevindb Nov 1, 2026
9f3123c
fix: call every error and complete callback given as an array
kevindb Nov 1, 2026
def1c87
fix: call success once when the target matches nothing
kevindb Nov 1, 2026
dbf072e
fix: call callbacks with the caller's context object
kevindb Nov 1, 2026
02d5190
fix: resolve one request method after the hooks, method over type
kevindb Nov 1, 2026
1a0e7ef
fix: send a string data option as a query string
kevindb Nov 1, 2026
cf0c637
feat: throw a clear error when ajaxSubmit runs on jQuery's slim build…
kevindb Nov 1, 2026
d7896f5
docs: record the submission fixes metrics and plan status
kevindb Nov 1, 2026
3d0b159
feat: add requestFormat "json" to send the form as a JSON body (#545)
kevindb Nov 1, 2026
81f0b79
docs: record the requestFormat metrics and plan status
kevindb Nov 1, 2026
d3c72b7
ci: follow callbacks run by helper functions in the CodeQL queries
kevindb Nov 1, 2026
423dae3
refactor: read the iframe response in its own module
kevindb Nov 1, 2026
139bd1e
refactor: build and post the iframe form in its own module
kevindb Nov 1, 2026
d5a9535
refactor: run the iframe upload lifecycle from its own module
kevindb Nov 1, 2026
03ce033
fix: fire the iframe upload's events in $.ajax order
kevindb Nov 1, 2026
9abb0bd
fix: settle an iframe upload once when it fails with an exception
kevindb Nov 1, 2026
fdd9b89
fix: cancel the delayed iframe post when the upload is aborted (D-16)
kevindb Nov 1, 2026
8b1c23a
fix: name iframe upload frames apart with a counter (D-22)
kevindb Nov 1, 2026
a66ce62
fix: read the iframe upload's dataType without regard to case (D-21)
kevindb Nov 1, 2026
43e9b2e
fix: name the window of an unnamed iframeTarget already in the page (…
kevindb Nov 1, 2026
4fb8354
docs: record the iframe lifecycle metrics and plan status
kevindb Nov 1, 2026
76b790c
test: pin that an ajaxSend abort still stops the iframe post after be…
kevindb Nov 1, 2026
4abb94a
refactor: decide the successful controls in their own module
kevindb Nov 1, 2026
cc9a27b
fix: send a control once when its form attribute names its own form
kevindb Nov 1, 2026
e2afea7
fix: skip named fieldset, output and object elements when serializing
kevindb Nov 1, 2026
39da7b1
fix: send a clicked image that is the form's only control (D-34)
kevindb Nov 1, 2026
1399556
fix: send selected files by name and upload outside file inputs (D-03)
kevindb Nov 1, 2026
d6fa2e1
fix: skip forms in fieldSerialize (D-28)
kevindb Nov 1, 2026
f2f49f1
fix: leave out controls in a disabled fieldset or optgroup, as native…
kevindb Nov 1, 2026
9868d02
fix: send only the controls a form owns in semantic mode, as native s…
kevindb Nov 1, 2026
7a87828
fix: send a lone carriage return as CRLF on every jQuery version (D-26)
kevindb Nov 1, 2026
7d7b009
docs: record the successful controls metrics and plan status
kevindb Nov 1, 2026
3d8692c
fix: let formToArray use an overridden $.fieldValue again
kevindb Nov 1, 2026
7bdd9fd
docs: plan the fieldValue override decision for 5.0
kevindb Nov 1, 2026
a89ce16
refactor: read and record the submitter through one module
kevindb Nov 1, 2026
e1b8716
fix: keep the clicked submitter when controls are named clk, clk_x or…
kevindb Nov 1, 2026
611711c
fix: send the submitter a submit event names when no click was captured
kevindb Nov 1, 2026
c9f9078
fix: send file names in the query string of a GET upload
kevindb Nov 1, 2026
b3cc969
docs: record the submitter metrics and plan status
kevindb Nov 1, 2026
857517b
refactor: move ajaxForm binding to src/ajax-form.js
kevindb Nov 1, 2026
1ab5b17
feat: scope ajaxForm delegation with delegation: "<selector>"
kevindb Nov 1, 2026
878a070
feat: remove delegated bindings with ajaxFormUnbind(), one with ajaxF…
kevindb Nov 1, 2026
38a840f
feat: warn that delegation: true binds every form on jQuery 3 and later
kevindb Nov 1, 2026
160f81b
docs: document delegation selectors, ajaxFormUnbind(selector) and the…
kevindb Nov 1, 2026
c40a78d
feat: warn under debug about features removed in 5.0
kevindb Nov 1, 2026
e753aa1
test: pin that dataFilter runs before target on both transports
kevindb Nov 1, 2026
8db5746
docs: document target sanitizing, trusted options and iframe responses
kevindb Nov 1, 2026
d0b434e
fix: keep the value of checkboxes, radios, hidden inputs and buttons …
kevindb Nov 1, 2026
57869a8
fix: empty file inputs on resetForm instead of throwing
kevindb Nov 1, 2026
0b3dc56
fix: select the last default option of a single select on resetForm
kevindb Nov 1, 2026
4405241
fix: clear datetime-local inputs in clearForm and clearFields
kevindb Nov 1, 2026
07987bd
fix: recognize a multipart enctype without regard to case or spaces
kevindb Nov 1, 2026
d0bbb42
fix: keep a custom xhr factory when uploadProgress is given
kevindb Nov 1, 2026
c369e04
fix: report position 0 for an upload progress event with loaded 0
kevindb Nov 1, 2026
1dad38c
fix: cancel a FormData upload when beforeSend returns false
kevindb Nov 1, 2026
57b241b
fix: re-enable disabled controls before a closeKeepAlive request
kevindb Nov 1, 2026
c6aec7d
docs: record the final Phase 12 metrics, deprecations and plan status
kevindb Nov 1, 2026
7e4d738
docs: plan 4.x test hardening as Phase 13 and move 5.0 to Phase 14
kevindb Nov 2, 2026
f23e10b
feat: deprecate the closeKeepAlive option with a debug warning
kevindb Nov 2, 2026
10cc5c8
docs: release Phase 12 as 4.5.0 and Phase 13 as 4.6.0
kevindb Nov 2, 2026
5847878
chore: release 4.5.0
kevindb Nov 10, 2026
43b52e5
docs: record the 4.5.0 release metrics and plan status
kevindb Nov 10, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 48 additions & 11 deletions .github/codeql/jquery-form-queries/JQueryFormSecurity.qll
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,59 @@ predicate objectKeyStep(DataFlow::Node pred, DataFlow::Node succ) {
}

/**
* Holds if `callbacks[i].apply(context, [a, b])` passes `pred` to `succ`, a parameter of a
* function pushed onto `callbacks`.
* A function value tracked from where it is created, through helper returns, parameters and
* imports or exports between modules.
*/
private DataFlow::SourceNode trackedFunction(DataFlow::FunctionNode f, DataFlow::TypeTracker t) {
t.start() and result = f
or
exists(DataFlow::TypeTracker t2 | result = trackedFunction(f, t2).track(t2, t))
}

/**
* An array tracked from where it is created, through helper parameters and returns and imports
* or exports between modules.
*/
private DataFlow::SourceNode trackedArray(DataFlow::ArrayCreationNode a, DataFlow::TypeTracker t) {
t.start() and result = a
or
exists(DataFlow::TypeTracker t2 | result = trackedArray(a, t2).track(t2, t))
}

/** Holds if `node` may hold the array created at `a`. */
private predicate isArray(DataFlow::ArrayCreationNode a, DataFlow::Node node) {
trackedArray(a, DataFlow::TypeTracker::end()).flowsTo(node)
}

/** Holds if `callback` is pushed onto the array created at `list`, wherever either is used. */
private predicate pushedCallback(DataFlow::ArrayCreationNode list, DataFlow::FunctionNode callback) {
exists(DataFlow::MethodCallNode push |
push.getMethodName() = "push" and
isArray(list, push.getReceiver()) and
trackedFunction(callback, DataFlow::TypeTracker::end()).flowsTo(push.getAnArgument())
)
}

/**
* Holds if `list[i].apply(context, [a, b])` or `list[i].call(context, a, b)` passes `pred` to
* `succ`, a parameter of a function pushed onto `list`. The list, the callbacks and the
* arguments array may each come from another function or module.
*/
predicate callbackListStep(DataFlow::Node pred, DataFlow::Node succ) {
exists(
DataFlow::MethodCallNode apply, DataFlow::ArrayCreationNode args, DataFlow::MethodCallNode push,
DataFlow::FunctionNode callback, Variable list, int i
DataFlow::MethodCallNode invoke, DataFlow::ArrayCreationNode list,
DataFlow::FunctionNode callback, int i
|
apply.getMethodName() = "apply" and
refersTo(apply.getReceiver().(DataFlow::PropRead).getBase(), list, "") and
args = apply.getArgument(1).getALocalSource() and
push.getMethodName() = "push" and
refersTo(push.getReceiver(), list, "") and
push.getAnArgument().getALocalSource() = callback and
pred = args.getElement(i) and
isArray(list, invoke.getReceiver().(DataFlow::PropRead).getBase()) and
pushedCallback(list, callback) and
succ = callback.getParameter(i)
|
invoke.getMethodName() = "apply" and
exists(DataFlow::ArrayCreationNode args |
isArray(args, invoke.getArgument(1)) and pred = args.getElement(i)
)
or
invoke.getMethodName() = "call" and pred = invoke.getArgument(i + 1)
)
}

Expand Down
4 changes: 4 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ _Avoid_: master, develop, next (as standing integration branches), trunk (as a b
**v4 line**:
The 4.x compatibility release line (legacy jQuery and shim support retained). After 5.0 ships, patches still belong to this line.
_Avoid_: old major, legacy branch (when meaning the release line rather than a git ref)

**form member**:
A property or method of a `<form>` element (such as `elements`, `ownerDocument`, `getAttribute`, `submit`, `reset`) as the DOM defines it, read or called through the DOM prototypes so that a control with the same name cannot shadow it.
_Avoid_: form property (a control named like it replaces `form.name`), form attribute (the HTML attribute is separate)
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ Please note that this project is released with a [Contributor Code of Conduct](C
### Security
Please report security issues privately, not in public issues. See [SECURITY](SECURITY.md).

Some options must be trusted input only, and a `target` response is inserted as HTML; see [Trusted options](docs/options.md#trusted-options) and the [`target`](docs/options.md#target) sanitizing recipe. Iframe uploads need HTML-safe responses; see [`iframe`](docs/options.md#iframe).

## Compatibility
* Requires jQuery 1.7.2 or later. `main` is tested against jQuery 1.7.2, 3.7.1 and 4.0.0.
* jQuery 4 needs 4.4.0 or later; 4.3.0 uses APIs that jQuery 4 removed.
* With `delegation: true` on jQuery 3 and later, every form on the page is handled, not only the selected ones. ([issue #353](https://github.com/jquery-form/form/issues/353))
* With `delegation: true` on jQuery 3 and later, every form on the page is handled, not only the selected ones; use `delegation: "<selector>"` instead. ([issue #353](https://github.com/jquery-form/form/issues/353))
* **Not** compatible with the jQuery slim builds, which leave out AJAX.

## Download
Expand Down Expand Up @@ -59,6 +61,14 @@ $('form').ajaxForm({
});
````

### ajaxFormUnbind( [selector] )
Removes the handlers `ajaxForm` bound on the selection, and every delegated binding (`delegation: true` or a selector) the plugin made on the document. With a selector string it removes only that delegated binding and leaves the selection's handlers alone. Calling `ajaxForm` again on a form does not remove delegated bindings.

````javascript
$('#myForm').ajaxFormUnbind(); // the form's handlers and all delegated bindings
$(document).ajaxFormUnbind('form.ajax'); // one delegated binding
````

### ajaxSubmit( options )
Immediately submits the form via AJAX. In the most common use case this is invoked in response to the user clicking a submit button on the form.
Use ajaxSubmit if you want to bind your own submit handler to the form.
Expand Down Expand Up @@ -136,18 +146,20 @@ Expected data type of the response. One of: null, 'xml', 'script', or 'json'. Th
* 'script': server response is evaluated in the global context

### delegation
true to enable support for event delegation
A selector string, or `true`, to handle forms through a document-level (delegated) binding, so forms added later are handled too.
*requires jQuery v1.7+*

**Note:** jQuery 3.0 removed the selector information this option relied on, so on jQuery 3 and later delegation is not limited to the selected forms; every form submit on the page is handled. See `docs/research/selector-context-delegation.md`.
With a selector, a form is submitted through the plugin when it, or an element around it, matches the selector. The selection `ajaxForm` is called on is ignored. Binding the same selector again replaces its options. An empty string throws an error.

````javascript
// prepare all existing and future forms for ajax submission
$('form').ajaxForm({
delegation: true
// prepare existing and future forms with class "ajax" for ajax submission
$(document).ajaxForm({
delegation: 'form.ajax'
});
````

**Warning:** `delegation: true` uses the selection's selector, which jQuery 3.0 removed. On jQuery 3 and later it binds **every form on the page**, so the options (`data`, `headers`) go with any form's submission. The plugin logs a `console.warn` for each such call, even with `debug` off. Use a selector. jQuery 5.0 support will require one.

### error
Callback function to be invoked upon error. It is passed the following arguments:

Expand Down Expand Up @@ -175,6 +187,9 @@ The HTTP method to use for the request (e.g. 'POST', 'GET', 'PUT').
### replaceTarget
Optionally used along with the target option. Set to true if the target should be replaced or false if only the target contents should be replaced.

### requestFormat
Set to `"json"` to send the fields (repeated names as arrays) merged with object `data` as a JSON body, with `contentType: "application/json; charset=UTF-8"`. Throws with a GET method, string `data`, files or the iframe transport. Based on the idea in PR #557 by zhangciwu.

### resetForm
Boolean flag indicating whether the form should be reset if the submit is successful

Expand Down
Loading
Loading