Skip to content

Commit 0546722

Browse files
committed
printf: use is_ascii_control() for shell quoting
Replace manual ASCII control char check with is_ascii_control() to properly handle both chars 0-31 and DEL (0x7F).
1 parent eb2ea58 commit 0546722

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/uucore/src/lib/features/quoting_style/shell_quoter.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,8 @@ fn initial_quoting(
191191
always_quote: bool,
192192
check_control_chars: bool,
193193
) -> (Quotes, bool) {
194-
const ASCII_CONTROL_LIMIT: u8 = 32;
195-
196194
let has_special_chars = input.iter().any(|c| {
197-
shell_escaped_char_set(dirname).contains(c)
198-
|| (check_control_chars && *c < ASCII_CONTROL_LIMIT)
195+
shell_escaped_char_set(dirname).contains(c) || (check_control_chars && c.is_ascii_control())
199196
});
200197

201198
if has_special_chars {
@@ -255,7 +252,7 @@ mod tests {
255252

256253
#[test]
257254
fn test_initial_quoting() {
258-
// Control chars (< 32) force single quotes in escape mode
255+
// Control chars (0-31 and 0x7F) force single quotes in escape mode
259256
assert_eq!(
260257
initial_quoting(b"\x01", false, false, true),
261258
(Quotes::Single, true)

0 commit comments

Comments
 (0)