1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-12 18:42:18 -05:00
denoland-deno/ext/node
Kenta Moriuchi ab60d9e6a3
fix: strict type check for cross realms (#21669)
Deno v1.39 introduces `vm.runInNewContext`. This may cause problems when
using `Object.prototype.isPrototypeOf` to check built-in types.

```js
import vm from "node:vm";

const err = new Error();
const crossErr = vm.runInNewContext(`new Error()`);

console.assert( !(crossErr instanceof Error) );
console.assert( Object.getPrototypeOf(err) !== Object.getPrototypeOf(crossErr) );
```

This PR changes to check using internal slots solves them.

---

current: 

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error {}
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
Date {}
```

this PR:

```
> import vm from "node:vm";
undefined
> vm.runInNewContext(`new Error("message")`)
Error: message
    at <anonymous>:1:1
> vm.runInNewContext(`new Date("2018-12-10T02:26:59.002Z")`)
2018-12-10T02:26:59.002Z
```

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
2024-01-04 20:34:55 +01:00
..
benchmarks fix: implement child_process IPC (#21490) 2023-12-13 11:14:16 +01:00
ops chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
polyfills fix: strict type check for cross realms (#21669) 2024-01-04 20:34:55 +01:00
analyze.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
build.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
Cargo.toml chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
clippy.toml refactor(ext/fs): deno_fs::FileSystem - conditional Send + Sync (#18993) 2023-05-08 11:02:02 -04:00
errors.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
global.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
lib.rs fix(ext/node): querystring stringify without encode callback (#21740) 2024-01-04 20:34:52 +01:00
package_json.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
path.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
polyfill.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00
README.md chore(ext/node): correct publishing for ext/node (#15461) 2022-08-11 17:25:41 -04:00
resolution.rs chore: update copyright to 2024 (#21753) 2024-01-04 20:34:51 +01:00

deno_node

require and other node related functionality for Deno.