xref: /PHP-8.4/ext/enchant/tests/null_bytes.phpt (revision 783ecad8)
1--TEST--
2null bytes
3--EXTENSIONS--
4enchant
5--SKIPIF--
6<?php
7$broker = enchant_broker_init();
8if (!enchant_broker_list_dicts($broker)) die("skip No broker dicts installed");
9?>
10--FILE--
11<?php
12
13$broker = enchant_broker_init();
14$dicts = enchant_broker_list_dicts($broker);
15$requestDict = enchant_broker_request_dict($broker, $dicts[0]['lang_tag']);
16
17$two_params_broker = [
18    "enchant_broker_request_dict",
19    "enchant_broker_dict_exists",
20];
21
22$two_params_dict = [
23    "enchant_dict_quick_check",
24    "enchant_dict_check",
25    "enchant_dict_suggest",
26    "enchant_dict_add",
27    "enchant_dict_add_to_session",
28    "enchant_dict_is_added",
29];
30
31foreach ($two_params_broker as $func) {
32    try {
33        $func($broker, "foo\0bar");
34    } catch (ValueError $e) {
35        echo $e->getMessage(), "\n";
36    }
37}
38
39foreach ($two_params_dict as $func) {
40    try {
41        $func($requestDict, "foo\0bar");
42    } catch (ValueError $e) {
43        echo $e->getMessage(), "\n";
44    }
45}
46
47try {
48    var_dump(enchant_broker_set_ordering($broker, "foo\0bar", "foo\0bar"));
49} catch (ValueError $e) {
50    echo $e->getMessage(), "\n";
51}
52
53try {
54    var_dump(enchant_dict_store_replacement($requestDict, "foo\0bar", "foo\0bar"));
55} catch (ValueError $e) {
56    echo $e->getMessage(), "\n";
57}
58
59?>
60--EXPECT--
61enchant_broker_request_dict(): Argument #2 ($tag) must not contain any null bytes
62enchant_broker_dict_exists(): Argument #2 ($tag) must not contain any null bytes
63enchant_dict_quick_check(): Argument #2 ($word) must not contain any null bytes
64enchant_dict_check(): Argument #2 ($word) must not contain any null bytes
65enchant_dict_suggest(): Argument #2 ($word) must not contain any null bytes
66enchant_dict_add(): Argument #2 ($word) must not contain any null bytes
67enchant_dict_add_to_session(): Argument #2 ($word) must not contain any null bytes
68enchant_dict_is_added(): Argument #2 ($word) must not contain any null bytes
69enchant_broker_set_ordering(): Argument #2 ($tag) must not contain any null bytes
70enchant_dict_store_replacement(): Argument #2 ($misspelled) must not contain any null bytes
71