Skip to content

Commit db6d9ef

Browse files
committed
Fix: panic on empty environment variable name provided for set_env command
1 parent 4c99c7d commit db6d9ef

7 files changed

Lines changed: 47 additions & 34 deletions

File tree

.buildnumber

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

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## CHANGELOG
22

3+
### v0.9.1 (2023-09-17)
4+
5+
* Fix: panic on empty environment variable name provided for set_env command
6+
37
### v0.9.0 (2023-09-08)
48

59
* Fix: Runtime - \[Breaking Change\] Empty spread should not count as an empty string argument #354

Cargo.lock

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

duckscript_cli/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "duckscript_cli"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
authors = ["Sagie Gur-Ari <sagiegurari@gmail.com>"]
55
description = "The duckscript command line executable."
66
license = "Apache-2.0"
@@ -28,7 +28,7 @@ path = "src/main.rs"
2828

2929
[dependencies]
3030
duckscript = { version = "^0.8.0", path = "../duckscript" }
31-
duckscriptsdk = { version = "^0.9.0", path = "../duckscript_sdk", default-features = false }
31+
duckscriptsdk = { version = "^0.9.1", path = "../duckscript_sdk", default-features = false }
3232

3333
[features]
3434
tls-rustls = ["duckscriptsdk/tls-rustls"]

duckscript_sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "duckscriptsdk"
3-
version = "0.9.0"
3+
version = "0.9.1"
44
authors = ["Sagie Gur-Ari <sagiegurari@gmail.com>"]
55
description = "The duckscript SDK."
66
license = "Apache-2.0"

duckscript_sdk/src/sdk/std/env/set_env/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ impl Command for CommandImpl {
5050
CommandResult::Error("Missing environment variable name and value.".to_string())
5151
} else if arguments.len() == 1 {
5252
CommandResult::Error("Missing environment variable value.".to_string())
53+
} else if arguments[0].is_empty() {
54+
CommandResult::Error("Environment variable name is empty string.".to_string())
5355
} else {
5456
if arguments[0] == "--handle" {
5557
let state = get_handles_sub_state(state);
@@ -60,8 +62,10 @@ impl Command for CommandImpl {
6062
Some(state_value) => match state_value {
6163
StateValue::SubState(map) => {
6264
for (env_key, env_value) in map {
63-
if let Ok(env_value_string) = get_as_string(env_value) {
64-
env::set_var(&env_key, &env_value_string);
65+
if !env_key.is_empty() {
66+
if let Ok(env_value_string) = get_as_string(env_value) {
67+
env::set_var(&env_key, &env_value_string);
68+
}
6569
}
6670
}
6771

duckscript_sdk/src/sdk/std/env/set_env/mod_test.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ fn run_single_argument() {
1717
test::run_script_and_error(vec![create("")], "out = set_env key", "out");
1818
}
1919

20+
#[test]
21+
fn run_empty_var_name() {
22+
test::run_script_and_error(vec![create("")], "out = set_env \"\" value", "out");
23+
}
24+
2025
#[test]
2126
fn run_set() {
2227
env::remove_var("DUCKSCRIPT_SDK_SET_ENV");

0 commit comments

Comments
 (0)