summaryrefslogtreecommitdiff
path: root/ext/json/tests/bug54058.phpt
blob: 08c7f579ab90b2344078832cc1638064f14230d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
--TEST--
Bug #54058 (json_last_error() invalid UTF-8 produces wrong error)
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php

$bad_utf8 = quoted_printable_decode('=B0');

json_encode($bad_utf8);
var_dump(json_last_error());

$a = new stdclass;
$a->foo = quoted_printable_decode('=B0');
json_encode($a);
var_dump(json_last_error());

$b = new stdclass;
$b->foo = $bad_utf8;
$b->bar = 1;
json_encode($b);
var_dump(json_last_error());

$c = array(
    'foo' => $bad_utf8,
    'bar' => 1
);
json_encode($c);
var_dump(json_last_error());
?>
--EXPECTF--
Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
int(5)

Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
int(5)

Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
int(5)

Warning: json_encode(): Invalid UTF-8 sequence in argument in %s on line %d
int(5)