buffer: isUtf8 and isAscii accept detached TypedArray views
### Version
latest main branch
### Platform
```text
7.1.2-arch3-1
```
### Subsystem
buffer
### What steps will reproduce the bug?
```js
const { isUtf8, isAscii } = require('node:buffer');
const view = new Uint8Array([0xff]);
structuredClone(view.buffer, { transfer: [view.buffer] });
console.log(isUtf8(view));
console.log(isAscii(view));
```
### How often does it reproduce? Is there a required condition?
ArrayBufferViewContents reads the view's zero byte length but does not record the detached state of its backing ArrayBuffer.
### What is the expected behavior? Why is that the expected behavior?
Both functions should throw ERR_INVALID_STATE, consistent with passing a detached ArrayBuffer directly.
### What do you see instead?
Both functions return true.
### Additional information
4 条评论