/
vshmidt
/
php
Обзор
Документация
Войти
/
vshmidt
/
php
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
ext/mbstring/tests/htmlent_encoding.phpt
68 строк
3 KB
Alex Dowad
Fix new conversion filter for HTML entities
18 июл 2022, 16:11
18 июл 2022, 16:11
fa83a8e
Код
Авторство
О чём код?
--TEST-- Temporary test of mbstring's HTML-ENTITIES 'encoding' --EXTENSIONS-- mbstring --FILE-- <?php /* Using mbstring to convert strings to and from HTML entities has already been deprecated * So this test should be removed when the HTML-ENTITIES 'encoding' is */ function convertToEntities($raw, $htmlent) { $converted = mb_convert_encoding($raw, 'HTML-ENTITIES', 'UTF-8'); if ($converted !== $htmlent) die('Expected ' . bin2hex($raw) . ' to convert to "' . $htmlent . '"; actually got "' . $converted . '"'); } function convertFromEntities($raw, $htmlent) { $converted = mb_convert_encoding($htmlent, 'UTF-8', 'HTML-ENTITIES'); if ($converted !== $raw) die('Expected "' . $htmlent . '" to convert to ' . bin2hex($raw) . '; actually got ' . bin2hex($converted)); } function testConversion($raw, $htmlent) { convertToEntities($raw, $htmlent); convertFromEntities($raw, $htmlent); } testConversion('', ''); testConversion('abc', 'abc'); testConversion('&<>', '&<>'); convertFromEntities('"', '"'); convertFromEntities("\xC3\xAC", 'ì'); convertFromEntities('あ', 'あ'); testConversion('あ', 'あ'); testConversion('abcあxyz', 'abcあxyz'); convertFromEntities('&#x;', '&#x;'); convertFromEntities('&#;', '&#;'); convertFromEntities('&#', '&#'); convertFromEntities('&', '&'); convertFromEntities("\x00", '�'); testConversion(str_repeat('あ', 100), str_repeat('あ', 100)); convertFromEntities("&;", "&;"); convertFromEntities("&f;", "&f;"); convertFromEntities("&A", "&A"); convertFromEntities("&A", "&A"); echo "Done!\n"; ?> --EXPECTF-- Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in %s Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in %s Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in %s Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in %s Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in %s Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in %s Done!