@@ -25,6 +25,8 @@ $test_cases = [
25
25
"\x00foo \x00\x00\x00bar \x00" ,
26
26
"\x00\x00\x00foo " ,
27
27
"foo \x00\x00\x00" ,
28
+ "\x80" , // << invalid UTF8
29
+ "\x00\x80\x00" , // << invalid UTF8
28
30
];
29
31
30
32
foreach ($ test_cases as $ test ){
@@ -38,7 +40,7 @@ $db->exec('CREATE TABLE test (name TEXT)');
38
40
39
41
foreach ($ test_cases as $ test_case ) {
40
42
$ quoted = $ db ->quote ($ test_case );
41
- echo trim (json_encode ($ test_case ), '" ' ), " -> $ quoted \n" ;
43
+ echo trim (json_encode ($ test_case, JSON_PARTIAL_OUTPUT_ON_ERROR ), '" ' ), " -> $ quoted \n" ;
42
44
$ db ->exec ("INSERT INTO test (name) VALUES ( " . $ quoted . ") " );
43
45
}
44
46
@@ -51,17 +53,19 @@ foreach ($stmt->fetchAll() as $result) {
51
53
--EXPECTF--
52
54
-> ''
53
55
x -> 'x'
54
- \u0000 -> x'00'
55
- a\u0000b -> x'610062'
56
- \u0000\u0000\u0000 -> x'000000'
56
+ \u0000 -> (''|| x'00')
57
+ a\u0000b -> (''|| x'610062')
58
+ \u0000\u0000\u0000 -> (''|| x'000000')
57
59
foobar -> 'foobar'
58
60
foo'''bar -> 'foo''''''bar'
59
61
'foo'''bar' -> '''foo''''''bar'''
60
- 'foo'\u0000'bar' -> x'27666F6F27002762617227'
61
- foo\u0000\u0000\u0000bar -> x'666F6F000000626172'
62
- \u0000foo\u0000\u0000\u0000bar\u0000 -> x'00666F6F00000062617200'
63
- \u0000\u0000\u0000foo -> x'000000666F6F'
64
- foo\u0000\u0000\u0000 -> x'666F6F000000'
62
+ 'foo'\u0000'bar' -> (''||x'27666F6F27002762617227')
63
+ foo\u0000\u0000\u0000bar -> (''||x'666F6F000000626172')
64
+ \u0000foo\u0000\u0000\u0000bar\u0000 -> (''||x'00666F6F00000062617200')
65
+ \u0000\u0000\u0000foo -> (''||x'000000666F6F')
66
+ foo\u0000\u0000\u0000 -> (''||x'666F6F000000')
67
+ null -> '€'
68
+ null -> (''||x'008000')
65
69
string(0) ""
66
70
string(1) "x"
67
71
string(1) "%0"
@@ -75,3 +79,5 @@ string(9) "foo%0%0%0bar"
75
79
string(11) "%0foo%0%0%0bar%0"
76
80
string(6) "%0%0%0foo"
77
81
string(6) "foo%0%0%0"
82
+ string(1) "€"
83
+ string(3) "%0€%0"
0 commit comments