]> git.kaiwu.me - njs.git/commit
TextEncoder: fix copy-on-write in encodeInto()
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 30 Oct 2026 01:57:39 +0000 (18:57 -0700)
committerDmitry Volyntsev <xeioexception@gmail.com>
Mon, 2 Nov 2026 14:42:35 +0000 (06:42 -0800)
commit45fd801fce15afb43a2ef0c586e39126b997fcd8
tree9a7c8bc63992267a3415bd318e71d4d6a0c702cc
parent8fef12ae007c9868670fb71c9995706a908e8c7b
TextEncoder: fix copy-on-write in encodeInto()

Previously, TextEncoder.prototype.encodeInto() wrote directly into the
destination buffer without making a private copy of shared data.  As a
result, encoding into r.requestBuffer in nginx modified the request
body seen by subsequent reads.

Now, the buffer is made writable before the write, as is done for
typed arrays.

The issue was introduced in 409004cb (0.4.4).
src/njs_encoding.c
src/test/njs_unit_test.c