Skip to content

Conversation

@twiss
Copy link
Member

@twiss twiss commented Jan 29, 2026

Read and normalize the algorithm argument(s) before copying the bytes held by data arguments, to enable avoiding the copy if the operation is performed on the same thread (which is currently not possible because the algorithm object getters may modify the data).

This also matches the current behavior of Firefox, Safari, and Node.js (only Chrome implements the current spec properly).

Closes #422.


Preview | Diff

Read and normalize the algorithm argument(s) before copying the bytes
held by data arguments, to enable avoiding the copy if the operation
is performed on the same thread (which is currently not possible
because the algorithm object getters may modify the data).
@twiss twiss requested review from annevk and davidben January 29, 2026 13:33
@davidben
Copy link
Collaborator

I asked someone who worked on this at the time and, from their memory, this was done to avoid vulnerabilities caused by the user callback mutating the type system? (They said it might actually have @annevk who originally suggested this solution way back, hehe.) Of course the spec and WebIDL have changed since then, so not sure what's still needed.

I'll find an IDL expert on the Chromium side and get back to this.

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.

Consider reordering reading arguments to avoid copies

3 participants