Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(artifacts): reserve CON-with-trailing-space and CONIN$/CONOUT$

M3gA-Mindb9e343c2d5dd
diff --git a/crates/openhuman-app/src/artifact_commands.rs b/crates/openhuman-app/src/artifact_commands.rs
index b9bd66f40e..ca0d8842b3 100644
--- a/crates/openhuman-app/src/artifact_commands.rs
+++ b/crates/openhuman-app/src/artifact_commands.rs
@@ -176,10 +176,12 @@ fn sanitize_filename(name: &str) -> Result<String, String> {
if name.is_empty() {
return Err(format!("filename has no usable characters: {trimmed:?}"));
}
+ // Windows ignores spaces before the extension, so `CON .txt` is `CON`.
let stem = name
.split('.')
.next()
.unwrap_or_default()
+ .trim_end_matches(' ')
.to_ascii_uppercase();
// Win32 also treats the superscript digits ¹ ² ³ as COM/LPT port digits.
let port_digit = |rest: &str| {
@@ -189,10 +191,12 @@ fn sanitize_filename(name: &str) -> Result<String, String> {
(Some('1'..='9' | '¹' | '²' | '³'), None)
)
};
- let reserved = matches!(stem.as_str(), "CON" | "PRN" | "AUX" | "NUL")
- || ["COM", "LPT"]
- .iter()
- .any(|p| stem.strip_prefix(p).is_some_and(port_digit));
+ let reserved = matches!(
+ stem.as_str(),
+ "CON" | "PRN" | "AUX" | "NUL" | "CONIN$" | "CONOUT$"
+ ) || ["COM", "LPT"]
+ .iter()
+ .any(|p| stem.strip_prefix(p).is_some_and(port_digit));
if reserved {
name.insert(0, '_');
}
diff --git a/crates/openhuman-app/src/artifact_commands_tests.rs b/crates/openhuman-app/src/artifact_commands_tests.rs
index 40ad3ca7fd..4c32554a65 100644
--- a/crates/openhuman-app/src/artifact_commands_tests.rs
+++ b/crates/openhuman-app/src/artifact_commands_tests.rs
@@ -35,6 +35,9 @@ fn sanitize_maps_windows_special_names_to_one_plain_component() {
("nul.txt", "_nul.txt"),
("com1.log", "_com1.log"),
("LPT9", "_LPT9"),
+ ("CON .txt", "_CON .txt"),
+ ("conin$", "_conin$"),
+ ("CONOUT$.log", "_CONOUT$.log"),
("COM¹.txt", "_COM¹.txt"),
("lpt³.pdf", "_lpt³.pdf"),
("COM⁴.txt", "COM⁴.txt"),