Skip to content

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

fix(artifacts): treat superscript COM/LPT port digits as reserved

M3gA-Mind12e0727528ad
diff --git a/crates/openhuman-app/src/artifact_commands.rs b/crates/openhuman-app/src/artifact_commands.rs
index c886d3682a..b9bd66f40e 100644
--- a/crates/openhuman-app/src/artifact_commands.rs
+++ b/crates/openhuman-app/src/artifact_commands.rs
@@ -181,9 +181,18 @@ fn sanitize_filename(name: &str) -> Result<String, String> {
.next()
.unwrap_or_default()
.to_ascii_uppercase();
+ // Win32 also treats the superscript digits ¹ ² ³ as COM/LPT port digits.
+ let port_digit = |rest: &str| {
+ let mut chars = rest.chars();
+ matches!(
+ (chars.next(), chars.next()),
+ (Some('1'..='9' | '¹' | '²' | '³'), None)
+ )
+ };
let reserved = matches!(stem.as_str(), "CON" | "PRN" | "AUX" | "NUL")
- || ((stem.starts_with("COM") || stem.starts_with("LPT"))
- && matches!(stem.as_bytes().get(3..), Some([b'1'..=b'9'])));
+ || ["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 d854ebab8a..40ad3ca7fd 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"),
+ ("COM¹.txt", "_COM¹.txt"),
+ ("lpt³.pdf", "_lpt³.pdf"),
+ ("COM⁴.txt", "COM⁴.txt"),
("COM10.log", "COM10.log"),
("Console.txt", "Console.txt"),
] {