Skip to content

Commit b8ae132

Browse files
authored
v2.1.14 (#30863)
1 parent 5b85bda commit b8ae132

File tree

9 files changed

+84
-14
lines changed

9 files changed

+84
-14
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Releases.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ https://github.com/denoland/deno/releases
66
We also have one-line install commands at:
77
https://github.com/denoland/deno_install
88

9+
### 2.1.14 / 2025.05.13
10+
11+
- fix(ext/node): set default callback for `fs.close` (#30720)
12+
- fix(ext/node): validate `fs.close` callback function (#30679)
13+
- fix: reject running `.bat` and `.cmd` directly on windows (#30818)
14+
915
### 2.1.13 / 2025.05.13
1016

1117
- fix: handling of contradictory global permission flags (#29213)

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "deno"
5-
version = "2.1.13"
5+
version = "2.1.14"
66
authors.workspace = true
77
default-run = "deno"
88
edition.workspace = true

cli/lib/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.13
1+
2.1.14

cli/rt/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "denort"
5-
version = "2.1.13"
5+
version = "2.1.14"
66
authors.workspace = true
77
default-run = "denort"
88
edition.workspace = true

ext/node/polyfills/_fs/_fs_close.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
// Copyright 2018-2025 the Deno authors. MIT license.
22

3-
// TODO(petamoriken): enable prefer-primordials for node polyfills
4-
// deno-lint-ignore-file prefer-primordials
5-
6-
import type { CallbackWithError } from "ext:deno_node/_fs/_fs_common.ts";
3+
import {
4+
type CallbackWithError,
5+
makeCallback,
6+
} from "ext:deno_node/_fs/_fs_common.ts";
77
import { getValidatedFd } from "ext:deno_node/internal/fs/utils.mjs";
8-
import { core } from "ext:core/mod.js";
8+
import { core, primordials } from "ext:core/mod.js";
9+
10+
const {
11+
Error,
12+
ErrorPrototype,
13+
ObjectPrototypeIsPrototypeOf,
14+
} = primordials;
915

10-
export function close(fd: number, callback: CallbackWithError) {
16+
function defaultCloseCallback(err: Error | null) {
17+
if (err !== null) throw err;
18+
}
19+
20+
export function close(
21+
fd: number,
22+
callback: CallbackWithError = defaultCloseCallback,
23+
) {
1124
fd = getValidatedFd(fd);
25+
if (callback !== defaultCloseCallback) {
26+
callback = makeCallback(callback);
27+
}
28+
1229
setTimeout(() => {
1330
let error = null;
1431
try {
1532
// TODO(@littledivy): Treat `fd` as real file descriptor. `rid` is an
1633
// implementation detail and may change.
1734
core.close(fd);
1835
} catch (err) {
19-
error = err instanceof Error ? err : new Error("[non-error thrown]");
36+
error = ObjectPrototypeIsPrototypeOf(ErrorPrototype, err)
37+
? err as Error
38+
: new Error("[non-error thrown]");
2039
}
2140
callback(error);
2241
}, 0);

ext/process/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,20 @@ fn compute_run_cmd_and_check_permissions(
690690
command: arg_cmd.to_string(),
691691
error: Box::new(e),
692692
})?;
693+
if let Some(ext) = cmd.extension() {
694+
if cfg!(windows) && (ext == "bat" || ext == "cmd") {
695+
return Err(ProcessError::SpawnFailed {
696+
command: arg_cmd.to_string(),
697+
error: Box::new(
698+
std::io::Error::new(
699+
std::io::ErrorKind::PermissionDenied,
700+
"Use a shell to execute .bat or .cmd files",
701+
)
702+
.into(),
703+
),
704+
});
705+
}
706+
}
693707
check_run_permission(
694708
state,
695709
&RunQueryDescriptor::Path {

tests/unit/command_test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,28 @@ Deno.test(
775775
},
776776
);
777777

778+
Deno.test(
779+
{
780+
permissions: { run: true, read: true, write: true },
781+
ignore: Deno.build.os !== "windows",
782+
},
783+
async function rejectBatAndCmdFiles() {
784+
const tempDir = await Deno.makeTempDir();
785+
const fileName = tempDir + "/test.bat";
786+
const file = await Deno.open(fileName, {
787+
create: true,
788+
write: true,
789+
});
790+
791+
await assertRejects(async () => {
792+
await new Deno.Command(fileName, {
793+
args: ["&calc.exe"],
794+
}).output();
795+
}, Deno.errors.PermissionDenied);
796+
file.close();
797+
},
798+
);
799+
778800
Deno.test(
779801
{
780802
permissions: { run: true, read: true },

tests/unit_node/_fs/_fs_close_test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2018-2025 the Deno authors. MIT license.
22
import { assert, assertThrows, fail } from "@std/assert";
33
import { assertCallbackErrorUncaught } from "../_test_utils.ts";
4-
import { close, closeSync } from "node:fs";
4+
import { close, closeSync, openSync } from "node:fs";
55

66
Deno.test({
77
name: "ASYNC: File is closed",
@@ -101,3 +101,12 @@ Deno.test({
101101
},
102102
});
103103
});
104+
105+
Deno.test({
106+
name: "[std/node/fs] close with default callback if none is provided",
107+
}, async () => {
108+
const tempFile = await Deno.makeTempFile();
109+
const rid = openSync(tempFile, "r");
110+
close(rid);
111+
await Deno.remove(tempFile);
112+
});

0 commit comments

Comments
 (0)