1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/mbstring/tests/bug81298.phpt
Alex Dowad a2bc57e0e5 mb_detect_encoding will not return non-encodings
Among the text encodings supported by mbstring are several which are
not really 'text encodings'. These include Base64, QPrint, UUencode,
HTML entities, '7 bit', and '8 bit'.

Rather than providing an explicit list of text encodings which they are
interested in, users may pass the output of mb_list_encodings to
mb_detect_encoding. Since Base64, QPrint, and so on are included in
the output of mb_list_encodings, mb_detect_encoding can return one of
these as its 'detected encoding' (and in fact, this often happens).
Before mb_detect_encoding was enhanced so it could detect any of the
supported text encodings, this did not happen, and it is never desired.
2021-10-19 18:05:52 +02:00

21 lines
485 B
PHP

--TEST--
Bug #81298: mb_detect_encoding() segfaults when 7bit encoding is specified
--EXTENSIONS--
mbstring
--FILE--
<?php
var_dump(mb_detect_encoding("foobar.", "7bit"));
var_dump(mb_detect_encoding("foobar.", "7bit,ascii"));
var_dump(mb_detect_encoding("foobar.", "7bit,ascii,utf8"));
var_dump(mb_detect_encoding("foobar.", "html"));
var_dump(mb_detect_encoding("foobar.", "ascii,html"));
?>
--EXPECT--
bool(false)
string(5) "ASCII"
string(5) "ASCII"
bool(false)
string(5) "ASCII"