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

Remove newline normalization in construct the entry list #6624

Merged
merged 3 commits into from May 20, 2021

Conversation

annevk
Copy link
Member

@annevk annevk commented Apr 26, 2021

Copy link
Member

@andreubotella andreubotella left a comment

Choose a reason for hiding this comment

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

LGTM except for the textarea case.

As for the double normalization notes in #6287, I think I'll remove them so this PR can be merged just after it.

</li>
<li><p>Otherwise, if the <var>field</var> element is a <code>textarea</code> element,
<span>append an entry</span> to <var>entry list</var> with <var>name</var> and the <span
data-x="concept-fe-value">value</span> of the <var>field</var> element.</p></li>
Copy link
Member

Choose a reason for hiding this comment

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

<textarea> is a bit of a special case in that, in the current spec text, rather than being CRLF-normalized in the "append an entry" algorithm, it's normalized before that in the textarea wrapping transformation. But on Firefox and Safari, <textarea> values as observed from the FormData constructor are LF-normalized instead. And Firefox doesn't seem to implement wrap="hard", but Safari implements it by inserting LF newlines. So the wrapping transformation would have to be changed as well, though I'm not sure how that might interact with things like minlength.

Copy link
Member Author

Choose a reason for hiding this comment

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

Can this be a follow-up to adjust that algorithm accordingly or does form submission actually have to know the data came from a textarea?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, it can be a follow-up.

cc @mfreed7 so they know they'll have to implement the follow-up as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

As it's an existing issue with <textarea> it seems best separated from this. We should probably also do some cross-platform checks to ensure the LF behavior is used everywhere, if that's what we want to align on. (I'll make sure we track this in an issue before this is merged.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #6647.

source Outdated Show resolved Hide resolved
@andreubotella
Copy link
Member

WPT PR: web-platform-tests/wpt#28798

Browser bugs:

@annevk annevk marked this pull request as ready for review May 4, 2021 10:16
@annevk annevk requested a review from domenic May 4, 2021 10:25
source Show resolved Hide resolved
source Show resolved Hide resolved
@annevk annevk requested a review from domenic May 6, 2021 07:34
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

LGTM. Not sure what the status is on how all these PRs should land, and accompanying implementer interest/tests, but I assume you've got a handle on that...

andreubotella pushed a commit to andreubotella/html that referenced this pull request May 19, 2021
Complements whatwg#6287 and whatwg#6624.

Fixes whatwg#6647.

See also whatwg#6662 for further cleanup on the textarea data model.
annevk pushed a commit to web-platform-tests/wpt that referenced this pull request May 20, 2021
annevk pushed a commit that referenced this pull request May 20, 2021
User agents normalize newlines when serializing form data to text/plain, application/x-www-form-urlencoded, and multipart/form-data. (This can be observed through FormData or the formdata event.)

This additionally changes the input passed to the application/x-www-form-urlencoded and text/plain serializers to be a
list of name-value pairs, where the values are always strings rather than potentially File objects.

Tests: web-platform-tests/wpt#26740.

Follow-up: #6624 & #6697.

Closes #6247. Helps with whatwg/url#562.
@annevk annevk merged commit 94c4c99 into main May 20, 2021
@annevk annevk deleted the annevk/less-normalization-during-construction branch May 20, 2021 12:09
annevk pushed a commit that referenced this pull request May 20, 2021
Complements #6287 and #6624. See also #6662 for further cleanup on the textarea data model.

Fixes #6647.
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 27, 2021
… constructing the entry list, a=testonly

Automatic update from web-platform-tests
HTML: no newline normalization when constructing the entry list

For whatwg/html#6624 and whatwg/html#6697.
--

wpt-commits: a35aa4089a7498dd4e107828c0925823fe512c97
wpt-pr: 28798
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 27, 2021
… constructing the entry list, a=testonly

Automatic update from web-platform-tests
HTML: no newline normalization when constructing the entry list

For whatwg/html#6624 and whatwg/html#6697.
--

wpt-commits: a35aa4089a7498dd4e107828c0925823fe512c97
wpt-pr: 28798
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 29, 2021
… constructing the entry list, a=testonly

Automatic update from web-platform-tests
HTML: no newline normalization when constructing the entry list

For whatwg/html#6624 and whatwg/html#6697.
--

wpt-commits: a35aa4089a7498dd4e107828c0925823fe512c97
wpt-pr: 28798
FrankEnderman pushed a commit to FrankEnderman/cursemium that referenced this pull request Oct 29, 2021
Chrome used to perform newline normalization in form payloads early into
the form submission algorithm –in particular, during the entry list
construction–, along with an additional normalization at the point of
serializing the form data into `application/x-www-form-urlencoded` and
`text/plain` form payloads. The early normalization was spec compliant –
the late one wasn't, but was required because servers expected it.

This change implements some recent changes in the HTML spec that have
standardized this newline normalization behavior across browsers,
removing the early normalization entirely and replacing it with a late
normalization at the point of serializing, even for the
`multipart/form-data` enctype.

This change does not affect the submitted form payload for normal
user-triggered form submissions. It only changes how form entry lists
are inspected from Javascript using the `FormData` API and the
`formdata` event, and how form entries added from Javascript are
serialized (by fetching with a `FormData` body, or by modifying a form
submission through form-associated custom elements or through the
`formdata` event). As such, this change is implemented behind a
default-on `LateFormNewlineNormalization` feature flag.

This change implements the following HTML spec PRs:
whatwg/html#6287
whatwg/html#6624
whatwg/html#6697

See also:
https://blog.whatwg.org/newline-normalizations-in-form-submission

Intent to Ship:
https://groups.google.com/a/chromium.org/g/blink-dev/c/XULXQrbFznw

Fixed: 1167095
Change-Id: I0a28369aefe052c413a427733ef33d70988a13c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3226394
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936197}
mjfroman pushed a commit to mjfroman/moz-libwebrtc-third-party that referenced this pull request Oct 14, 2022
Chrome used to perform newline normalization in form payloads early into
the form submission algorithm –in particular, during the entry list
construction–, along with an additional normalization at the point of
serializing the form data into `application/x-www-form-urlencoded` and
`text/plain` form payloads. The early normalization was spec compliant –
the late one wasn't, but was required because servers expected it.

This change implements some recent changes in the HTML spec that have
standardized this newline normalization behavior across browsers,
removing the early normalization entirely and replacing it with a late
normalization at the point of serializing, even for the
`multipart/form-data` enctype.

This change does not affect the submitted form payload for normal
user-triggered form submissions. It only changes how form entry lists
are inspected from Javascript using the `FormData` API and the
`formdata` event, and how form entries added from Javascript are
serialized (by fetching with a `FormData` body, or by modifying a form
submission through form-associated custom elements or through the
`formdata` event). As such, this change is implemented behind a
default-on `LateFormNewlineNormalization` feature flag.

This change implements the following HTML spec PRs:
whatwg/html#6287
whatwg/html#6624
whatwg/html#6697

See also:
https://blog.whatwg.org/newline-normalizations-in-form-submission

Intent to Ship:
https://groups.google.com/a/chromium.org/g/blink-dev/c/XULXQrbFznw

Fixed: 1167095
Change-Id: I0a28369aefe052c413a427733ef33d70988a13c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3226394
Reviewed-by: Kent Tamura <tkent@chromium.org>
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/main@{#936197}
NOKEYCHECK=True
GitOrigin-RevId: 3a41107f23310a86c7fa4557be14e90b867baa01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

Consider not normalizing form entries during construction of the entry list
3 participants