Skip to content

Commit 5fde7ba

Browse files
committed
improve
1 parent 340ca0b commit 5fde7ba

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

usr/libexec/helper-scripts/strings.bsh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,18 +269,25 @@ tests() {
269269

270270
run_test "alpha_numeric: rejects empty" check_is_alpha_numeric 1 test_value ""
271271
run_test "alpha_numeric: rejects dot" check_is_alpha_numeric 1 test_value "."
272-
run_test "alpha_numeric: accepts simple token" check_is_alpha_numeric 0 test_value "test"
272+
run_test "alpha_numeric: rejects space" check_is_alpha_numeric 1 test_value "plain text"
273+
#run_test "alpha_numeric: rejects unicode" check_is_alpha_numeric 1 test_value "cafe"
274+
run_test "alpha_numeric: accepts token with dash/underscore" check_is_alpha_numeric 0 test_value "test_123-OK"
273275

274276
run_test "safe_filename: accepts simple name" validate_safe_filename 0 test_value "test"
277+
run_test "safe_filename: accepts spaces and punctuation" validate_safe_filename 0 test_value "plain text (v1) [ok].txt"
275278
run_test "safe_filename: rejects dot" validate_safe_filename 1 test_value "."
276279
run_test "safe_filename: rejects double dot" validate_safe_filename 1 test_value ".."
277280
run_test "safe_filename: rejects embedded double dot" validate_safe_filename 1 test_value "test..test"
281+
run_test "safe_filename: rejects slash" validate_safe_filename 1 test_value "dir/file"
282+
run_test "safe_filename: rejects backslash" validate_safe_filename 1 test_value $'dir\\file'
283+
run_test "safe_filename: rejects control char newline" validate_safe_filename 1 test_value $'hello\nworld'
284+
run_test "safe_filename: rejects leading dash" validate_safe_filename 1 test_value "-rf"
285+
run_test "safe_filename: rejects overlong name" validate_safe_filename 1 test_value "$(printf 'a%.0s' {1..256})"
278286

279287
run_test "one_line: rejects empty" check_is_not_empty_and_only_one_line 1 test_value ""
280288
run_test "one_line: rejects only whitespace/newlines" check_is_not_empty_and_only_one_line 1 test_value $'\n\n '
281-
run_test "one_line: rejects only spaces" check_is_not_empty_and_only_one_line 1 test_value " "
282-
run_test "one_line: accepts normal text" check_is_not_empty_and_only_one_line 0 test_value "Hello, World!"
283289
run_test "one_line: rejects multi-line string" check_is_not_empty_and_only_one_line 1 test_value $'Hello\nWorld'
290+
run_test "one_line: accepts normal text" check_is_not_empty_and_only_one_line 0 test_value "Hello, World!"
284291
run_test "one_line: accepts text with surrounding spaces" check_is_not_empty_and_only_one_line 0 test_value " Hello "
285292

286293
input_string=$'test1\ntest2'

0 commit comments

Comments
 (0)