@@ -25,6 +25,8 @@ $test_cases = [
2525 "\x00foo \x00\x00\x00bar \x00" ,
2626 "\x00\x00\x00foo " ,
2727 "foo \x00\x00\x00" ,
28+ "\x80" , // << invalid UTF8
29+ "\x00\x80\x00" , // << invalid UTF8
2830];
2931
3032foreach ($ test_cases as $ test ){
@@ -38,7 +40,7 @@ $db->exec('CREATE TABLE test (name TEXT)');
3840
3941foreach ($ test_cases as $ test_case ) {
4042 $ 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" ;
4244 $ db ->exec ("INSERT INTO test (name) VALUES ( " . $ quoted . ") " );
4345}
4446
@@ -51,17 +53,19 @@ foreach ($stmt->fetchAll() as $result) {
5153--EXPECTF--
5254-> ''
5355x -> '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')
5759foobar -> 'foobar'
5860foo'''bar -> 'foo''''''bar'
5961'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')
6569string(0) ""
6670string(1) "x"
6771string(1) "%0"
@@ -75,3 +79,5 @@ string(9) "foo%0%0%0bar"
7579string(11) "%0foo%0%0%0bar%0"
7680string(6) "%0%0%0foo"
7781string(6) "foo%0%0%0"
82+ string(1) "€"
83+ string(3) "%0€%0"
0 commit comments