Skip to content

script: Escape field names and values for default x-www-form-urlencoded <form> POST - #44953

Merged
yezhizhen merged 3 commits into
servo:mainfrom
yezhizhen:form-again
May 16, 2026
Merged

yezhizhen merged 3 commits into
servo:mainfrom
yezhizhen:form-again

Conversation

@yezhizhen

@yezhizhen yezhizhen commented May 16, 2026 •

Copy link
Copy Markdown
Member

Spec for submit entity body (POST) for x-www-form-urlencoded.

We also extract inner fn clean_crlf to normalize_crlf as this is widely common.
Follow up of #44943.

Testing: Passing in existing tests.
Part of #10778. (Well this isn't FileAPI, but that's what led me here.)

Signed-off-by: Euclid Ye <[email protected]>
@yezhizhen
yezhizhen requested a review from xiaochengh May 16, 2026 03:57
@yezhizhen
yezhizhen requested a review from gterzian as a code owner May 16, 2026 03:57
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 16, 2026
Signed-off-by: Euclid Ye <[email protected]>
buf
}

fn normalize_crlf_for_domstring(s: &DOMString) -> String {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be an impl DOMString?

@yezhizhen yezhizhen May 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We can try. We would need to change replace_value to return DOMString then. We can then save a function and some confusing string conversion it seems.

@yezhizhen yezhizhen May 16, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This refactor might deserve a separate review. It is more than a refactor as we need to remove some duplicate steps to make it happen.
Let me post it in a separate PR.

@servo-highfive servo-highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-review There is new code that needs to be reviewed. labels May 16, 2026
@yezhizhen
yezhizhen marked this pull request as draft May 16, 2026 07:48
Signed-off-by: Euclid Ye <[email protected]>
@yezhizhen
yezhizhen marked this pull request as ready for review May 16, 2026 08:59
@yezhizhen
yezhizhen added this pull request to the merge queue May 16, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 16, 2026
Merged via the queue into servo:main with commit 0d283f6 May 16, 2026
30 checks passed
@yezhizhen
yezhizhen deleted the form-again branch May 16, 2026 09:47
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label May 16, 2026
pull Bot pushed a commit to AKJUS/servo that referenced this pull request May 16, 2026
…vo#44954)

Sorry for the messy title. But there are quite a few things going on.
1. There was a redundant special casing in `fn replace_value`. It was
already done in
https://github.com/servo/servo/blob/0d283f6c2b484c712129b6ad41f8c2c7488d0447/components/script/dom/html/input_element/mod.rs#L1655-L1657
It is important to remove it, to make `fn replace_value` return
`&DOMString` without cloning and String conversion.

2. Move `normalize_crlf` to `impl DOMString`

Testing: [Try](https://github.com/servo/servo/actions/runs/25958542073).
This is refactor + removing redundant code.
Part of servo#10778
Addresses
servo#44953 (comment)

---------

Signed-off-by: Euclid Ye <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants