1--TEST--
2Bug #44703 (htmlspecialchars() does not detect bad character set argument)
3--FILE--
4<?php
5
6var_dump(htmlspecialchars("<a href='test'>Test</a>", ENT_COMPAT, 1));
7var_dump(htmlspecialchars("<a href='test'>Test</a>", ENT_COMPAT, 12));
8var_dump(htmlspecialchars("<a href='test'>Test</a>", ENT_COMPAT, 125));
9var_dump(htmlspecialchars("<a href='test'>Test</a>", ENT_COMPAT, 1252));
10var_dump(htmlspecialchars("<a href='test'>Test</a>", ENT_COMPAT, 12526));
11
12var_dump(htmlspecialchars("<>", ENT_COMPAT, 866));
13var_dump(htmlspecialchars("<>", ENT_COMPAT, 8666));
14
15var_dump(htmlspecialchars("<>", ENT_COMPAT, NULL));
16
17
18var_dump(htmlspecialchars("<>", ENT_COMPAT, 'SJIS'));
19var_dump(htmlspecialchars("<>", ENT_COMPAT, 'SjiS'));
20
21var_dump(htmlspecialchars("<>", ENT_COMPAT, str_repeat('a', 100)));
22
23?>
24--EXPECTF--
25Warning: htmlspecialchars(): Charset "1" is not supported, assuming UTF-8 in %s on line %d
26string(35) "&lt;a href='test'&gt;Test&lt;/a&gt;"
27
28Warning: htmlspecialchars(): Charset "12" is not supported, assuming UTF-8 in %s on line %d
29string(35) "&lt;a href='test'&gt;Test&lt;/a&gt;"
30
31Warning: htmlspecialchars(): Charset "125" is not supported, assuming UTF-8 in %s on line %d
32string(35) "&lt;a href='test'&gt;Test&lt;/a&gt;"
33string(35) "&lt;a href='test'&gt;Test&lt;/a&gt;"
34
35Warning: htmlspecialchars(): Charset "12526" is not supported, assuming UTF-8 in %s on line %d
36string(35) "&lt;a href='test'&gt;Test&lt;/a&gt;"
37string(8) "&lt;&gt;"
38
39Warning: htmlspecialchars(): Charset "8666" is not supported, assuming UTF-8 in %s on line %d
40string(8) "&lt;&gt;"
41string(8) "&lt;&gt;"
42string(8) "&lt;&gt;"
43string(8) "&lt;&gt;"
44
45Warning: htmlspecialchars(): Charset "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" is not supported, assuming UTF-8 in %s on line %d
46string(8) "&lt;&gt;"
47