Skip to content

fix(url): validate name in URLSearchParams.append()#320

Merged
andreiltd merged 1 commit into
bytecodealliance:mainfrom
watilde:fix/urlsearchparams-append-name-validation
Jul 20, 2026
Merged

fix(url): validate name in URLSearchParams.append()#320
andreiltd merged 1 commit into
bytecodealliance:mainfrom
watilde:fix/urlsearchparams-append-name-validation

Conversation

@watilde

@watilde watilde commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

URLSearchParams.append() never checked whether stringifying the name argument succeeded. For a non-stringifiable name (a Symbol, or an object whose toString throws), core::encode_spec_string returns a SpecString with a null data pointer and a pending exception, which append handed straight to the Rust params_append — crashing the process in slice::from_raw_parts (UB in release) instead of throwing.

Null-check the encoded name and propagate the pending exception, exactly as delete()/has()/get()/set() already do. Add an integration test.

@andreiltd andreiltd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@andreiltd

Copy link
Copy Markdown
Member

@watilde could you resolve conflicts? It is good to go otherwise.

URLSearchParams.append() never checked whether stringifying the name
argument succeeded. For a non-stringifiable name (a Symbol, or an
object whose toString throws), core::encode_spec_string returns a
SpecString with a null data pointer and a pending exception, which
append handed straight to the Rust params_append — crashing the process
in slice::from_raw_parts (UB in release) instead of throwing.

Null-check the encoded name and propagate the pending exception, exactly
as delete()/has()/get()/set() already do. Add an integration test.

Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
@watilde
watilde force-pushed the fix/urlsearchparams-append-name-validation branch from 761ed9e to 03a161d Compare July 20, 2026 13:53
@watilde

watilde commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@andreiltd Thanks for reviewing. Rebased onto main

@andreiltd
andreiltd merged commit fb47e0e into bytecodealliance:main Jul 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants