Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
refactor: Remove NUL terminator-related snapshot filters
Maximilian Roos1ff77e73c133
diff --git a/src/output/global.rs b/src/output/global.rsindex 5da05d055..248c71422 100644--- a/src/output/global.rs+++ b/src/output/global.rs@@ -183,11 +183,11 @@ pub fn flush() -> io::Result<()> {////// This prevents stream interleaving. Interactive prompts write to stderr, so we must/// ensure all previous output is flushed first:-/// - In directive mode: Flushes both stdout (directives) and stderr (messages)+/// - In directive mode: Flushes stderr (messages stream there in real-time)/// - In interactive mode: Flushes both stdout and stderr////// Note: With stderr separation (messages on stderr in directive mode), prompts-/// naturally appear after messages without needing NUL terminators for synchronization.+/// naturally appear after messages without needing special synchronization.pub fn flush_for_stderr_prompt() -> io::Result<()> {with_output(|h| h.flush_for_stderr_prompt())}diff --git a/src/output/interactive.rs b/src/output/interactive.rsindex 431220fc1..3acecac42 100644--- a/src/output/interactive.rs+++ b/src/output/interactive.rs@@ -91,7 +91,7 @@ impl OutputHandler for InteractiveOutput {}fn terminate_output(&mut self) -> io::Result<()> {- // No-op in interactive mode - no NUL terminators needed+ // No-op in interactive mode - shell script only emitted in directive modeOk(())}}diff --git a/tests/integration_tests/security.rs b/tests/integration_tests/security.rsindex 22edaafaf..3de4a7b25 100644--- a/tests/integration_tests/security.rs+++ b/tests/integration_tests/security.rs@@ -221,7 +221,6 @@ fn test_branch_name_is_directive_not_executed() {let mut settings = Settings::clone_current();settings.set_snapshot_path("../snapshots");- settings.add_filter(r"__WORKTRUNK_CD__[^\x00]+", "__WORKTRUNK_CD__[PATH]");settings.bind(|| {let mut cmd = wt_command();@@ -263,7 +262,6 @@ fn test_branch_name_with_newline_directive_not_executed() {let mut settings = Settings::clone_current();settings.set_snapshot_path("../snapshots");- settings.add_filter(r"__WORKTRUNK_CD__[^\x00]+", "__WORKTRUNK_CD__[PATH]");settings.bind(|| {let mut cmd = wt_command();@@ -375,8 +373,7 @@ fn test_branch_name_with_cd_directive_not_executed() {return;}- let mut settings = setup_snapshot_settings(&repo);- settings.add_filter(r"__WORKTRUNK_CD__[^\x00]+", "__WORKTRUNK_CD__[PATH]");+ let settings = setup_snapshot_settings(&repo);settings.bind(|| {let mut cmd = wt_command();@@ -426,8 +423,8 @@ fn test_error_message_with_directive_not_executed() {/// Test that execute flag (-x) input is properly handled////// The -x flag is SUPPOSED to execute commands, so this tests that:-/// 1. Commands from -x are executed via __WORKTRUNK_EXEC__-/// 2. User content in branch names that looks like directives doesn't inject extra executions+/// 1. Commands from -x are emitted as shell script to stdout+/// 2. User content in branch names that looks like old directives doesn't cause injection#[test]fn test_execute_flag_with_directive_like_branch_name() {let repo = TestRepo::new();@@ -450,7 +447,6 @@ fn test_execute_flag_with_directive_like_branch_name() {let mut settings = Settings::clone_current();settings.set_snapshot_path("../snapshots");- settings.add_filter(r"__WORKTRUNK_CD__[^\x00]+", "__WORKTRUNK_CD__[PATH]");settings.bind(|| {let mut cmd = wt_command();@@ -463,8 +459,8 @@ fn test_execute_flag_with_directive_like_branch_name() {.arg("echo legitimate command").current_dir(repo.root_path());- // Should see ONE __WORKTRUNK_EXEC__ from the -x flag- // The branch name should NOT create a second directive+ // The -x command should appear in stdout as shell script+ // The branch name should NOT inject additional commandsassert_cmd_snapshot!(cmd);});diff --git a/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap b/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snapindex 1488c286e..5ea3f5940 100644--- a/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap+++ b/tests/snapshots/integration__integration_tests__security__branch_name_with_cd_directive_not_executed.snap@@ -25,4 +25,6 @@ exit_code: 1----- stdout ---------- stderr ------❌ [31mBranch [1m[31m__WORKTRUNK_CD__[PATH]+❌ [31mBranch [1m[31m__WORKTRUNK_CD__/tmp[0m[31m already exists[0m++💡 [2mRemove --create flag to switch to it[0m