diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-11 21:17:55 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-11 21:17:55 +0100 |
commit | 58f108eb339957f58d5a6034d82b09c4d50b53e3 (patch) | |
tree | 4fdfae71136811f3b9c8ffd56656b78da19739da /testsuite/ash.tests | |
parent | b0a57abb79001b994115d2c96a7d9e1f2f511430 (diff) | |
download | busybox-w32-58f108eb339957f58d5a6034d82b09c4d50b53e3.tar.gz busybox-w32-58f108eb339957f58d5a6034d82b09c4d50b53e3.tar.bz2 busybox-w32-58f108eb339957f58d5a6034d82b09c4d50b53e3.zip |
lineedit: fix another corner case with bad unicode input
function old new delta
read_key 607 646 +39
readit 50 55 +5
getch_nowait 290 295 +5
hash_find 233 234 +1
xstrtoul_range_sfx 231 230 -1
passwd_main 1058 1056 -2
builtin_exit 45 43 -2
cmp_main 649 645 -4
lineedit_read_key 257 245 -12
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/5 up/down: 50/-21) Total: 29 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'testsuite/ash.tests')
-rwxr-xr-x | testsuite/ash.tests | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/testsuite/ash.tests b/testsuite/ash.tests index 4b6efe42c..6b2caf316 100755 --- a/testsuite/ash.tests +++ b/testsuite/ash.tests | |||
@@ -10,33 +10,47 @@ | |||
10 | # testing "test name" "options" "expected result" "file input" "stdin" | 10 | # testing "test name" "options" "expected result" "file input" "stdin" |
11 | 11 | ||
12 | testing "One byte which is not valid unicode char followed by valid input" \ | 12 | testing "One byte which is not valid unicode char followed by valid input" \ |
13 | "script -q -c 'ash' /dev/null >/dev/null; cat output; rm output" \ | 13 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
14 | "\ | 14 | "\ |
15 | 00000000 3f 2d 0a |?-.| | 15 | 00000000 3f 2d 0a |?-.| |
16 | 00000003 | 16 | 00000003 |
17 | " \ | 17 | " \ |
18 | "" \ | 18 | "" \ |
19 | "echo \xff- | hexdump -C >output; exit; exit; exit; exit\n" \ | 19 | "echo \xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
20 | 20 | ||
21 | testing "30 bytes which are not valid unicode chars followed by valid input" \ | 21 | testing "30 bytes which are not valid unicode chars followed by valid input" \ |
22 | "script -q -c 'ash' /dev/null >/dev/null; cat output; rm output" \ | 22 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
23 | "\ | 23 | "\ |
24 | 00000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????| | 24 | 00000000 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f |????????????????| |
25 | 00000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.| | 25 | 00000010 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 3f 2d 0a |??????????????-.| |
26 | 00000020 | 26 | 00000020 |
27 | " \ | 27 | " \ |
28 | "" \ | 28 | "" \ |
29 | "echo \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff- | hexdump -C >output; exit; exit; exit; exit\n" \ | 29 | "echo \xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
30 | 30 | ||
31 | # Not sure this behavior is perfect: we lose all invalid input which precedes | 31 | # Not sure this behavior is perfect: we lose all invalid input which precedes |
32 | # arrow keys and such. In this example, \xff\xff are lost | 32 | # arrow keys and such. In this example, \xff\xff are lost |
33 | testing "2 bytes which are not valid unicode chars followed by left arrow key" \ | 33 | testing "2 bytes which are not valid unicode chars followed by left arrow key" \ |
34 | "script -q -c 'ash' /dev/null >/dev/null; cat output; rm output" \ | 34 | "script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ |
35 | "\ | 35 | "\ |
36 | 00000000 3d 2d 0a |=-.| | 36 | 00000000 3d 2d 0a |=-.| |
37 | 00000003 | 37 | 00000003 |
38 | " \ | 38 | " \ |
39 | "" \ | 39 | "" \ |
40 | "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >output; exit; exit; exit; exit\n" \ | 40 | "echo =+\xff\xff\x1b\x5b\x44- | hexdump -C >ash.output; exit; exit; exit; exit\n" |
41 | |||
42 | # ash should see "echo \xff\n",pause -> execute it as "echo ?" (which is | ||
43 | # not checked by the test), then read and execute the rest: "echo A | ..." | ||
44 | # The bug was that ash was eating the beginning of "echo A" despite the pause. | ||
45 | testing "Invalid unicode chars followed by a pause do not eat next chars" \ | ||
46 | "{ echo -ne 'echo \xff\n'; sleep 1; echo -ne 'echo A | hexdump -C >ash.output; exit; exit; exit; exit\n'; } \ | ||
47 | | script -q -c 'ash' /dev/null >/dev/null; cat ash.output" \ | ||
48 | "\ | ||
49 | 00000000 41 0a |A.| | ||
50 | 00000002 | ||
51 | " \ | ||
52 | "" "" | ||
53 | |||
54 | rm ash.output | ||
41 | 55 | ||
42 | exit $FAILCOUNT | 56 | exit $FAILCOUNT |