Commit e120e8d
committed
fix: strip NUL bytes from history commands (closes #3589)
External tools (e.g. AI agents) can mis-escape values and write raw NUL
bytes into the shell history. NUL bytes break downstream consumers that
expect valid UTF-8 text — search output, pipes, messagepack serialisation,
and so on. Rather than reject the entire otherwise-useful entry, strip the
NUL bytes at the point where new history entries are constructed
(History::new), so clean and dirty paths alike are handled.
Adds a sanitize_command helper with a fast-path for the common case
(no NUL bytes present) and a test for both the stripped and clean paths.1 parent 95570e5 commit e120e8d
1 file changed
Lines changed: 44 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
129 | 147 | | |
130 | 148 | | |
131 | 149 | | |
| |||
152 | 170 | | |
153 | 171 | | |
154 | 172 | | |
155 | | - | |
| 173 | + | |
156 | 174 | | |
157 | 175 | | |
158 | 176 | | |
| |||
698 | 716 | | |
699 | 717 | | |
700 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
701 | 744 | | |
702 | 745 | | |
703 | 746 | | |
| |||
0 commit comments