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