Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "php.h"
#include "php_ini.h"
#include "php_variables.h"
#include "zend_attributes.h"
#include "mbstring.h"
#include "ext/standard/php_string.h"
#include "ext/standard/php_mail.h"
Expand Down
2 changes: 2 additions & 0 deletions ext/mbstring/mbstring.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
function mb_language(?string $language = null): string|bool {}

/** @refcount 1 */
#[\Deprecated(since: '8.5', message: 'use internal_encoding INI settings instead')]
function mb_internal_encoding(?string $encoding = null): string|bool {}

/**
Expand All @@ -64,6 +65,7 @@ function mb_internal_encoding(?string $encoding = null): string|bool {}
function mb_http_input(?string $type = null): array|string|false {}

/** @refcount 1 */
#[\Deprecated(since: '8.5', message: 'use output_encoding INI settings instead')]
function mb_http_output(?string $encoding = null): string|bool {}

/**
Expand Down
21 changes: 18 additions & 3 deletions ext/mbstring/mbstring_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion ext/mbstring/tests/bug45239.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ mb_internal_encoding("utf-8");
mb_parse_str("a=%fc", $dummy);
var_dump(mb_http_input());
?>
--EXPECT--
--EXPECTF--
Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"
14 changes: 14 additions & 0 deletions ext/mbstring/tests/bug48697.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,22 @@ var_dump(mb_internal_encoding());
?>
--EXPECTF--
Deprecated: ini_set(): Use of mbstring.internal_encoding is deprecated in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(11) "ISO-8859-15"

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"
2 changes: 2 additions & 0 deletions ext/mbstring/tests/bug69079.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Bug #69079 (enhancement for mb_substitute_character)
--EXTENSIONS--
mbstring
--INI--
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php

Expand Down
2 changes: 2 additions & 0 deletions ext/mbstring/tests/bug69086.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Request #69086 (enhancement for mb_convert_encoding)
--EXTENSIONS--
mbstring
--INI--
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
mb_substitute_character(0xfffd);
Expand Down
3 changes: 2 additions & 1 deletion ext/mbstring/tests/casefold.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ output_handler=
print mb_strtoupper( "äëï\n" );
print mb_convert_case( "äëï\n", MB_CASE_TITLE );
?>
--EXPECT--
--EXPECTF--
Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ÄËÏ
Expand Down
4 changes: 3 additions & 1 deletion ext/mbstring/tests/casemapping.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ echo mb_convert_case("ΚΑΛΗΣΠΕΡΑ ΣΑΣ", MB_CASE_LOWER, "UTF-8"), "\n";
echo mb_convert_case("ΚΑΛΗΣΠΕΡΑ ΣΑΣ", MB_CASE_LOWER_SIMPLE, "UTF-8"), "\n";

?>
--EXPECT--
--EXPECTF--
String: ß
Lower: ß
Lower Simple: ß
Expand Down Expand Up @@ -96,6 +96,8 @@ Title Simple: İ
Fold: i̇
Fold Simple: İ


Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
69
69
69
Expand Down
4 changes: 3 additions & 1 deletion ext/mbstring/tests/gh13815.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ $strSjis = mb_convert_encoding($strUtf8, 'Shift_JIS', 'UTF-8');
var_dump(mb_strlen(mb_trim($strSjis)));
var_dump(mb_strlen(mb_trim($strSjis, encoding: 'Shift_JIS')));
?>
--EXPECT--
--EXPECTF--
int(1)
int(1)

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
int(1)
int(1)
2 changes: 2 additions & 0 deletions ext/mbstring/tests/gh9535.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
GH-9535 (mb_strcut(): The behavior of mb_strcut in mbstring has been changed in PHP8.1)
--EXTENSIONS--
mbstring
--INI--
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php
$encodings = [
Expand Down
2 changes: 2 additions & 0 deletions ext/mbstring/tests/gh9535b.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Test output of mb_strcut for text encodings which use escape sequences
--EXTENSIONS--
mbstring
--INI--
error_reporting=E_ALL & ~E_DEPRECATED
--FILE--
<?php

Expand Down
4 changes: 3 additions & 1 deletion ext/mbstring/tests/ini_language.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ mbstring.language=Japanese
var_dump(ini_get('internal_encoding'));
var_dump(mb_internal_encoding());
?>
--EXPECT--
--EXPECTF--
string(9) "Shift_JIS"

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(4) "SJIS"
15 changes: 15 additions & 0 deletions ext/mbstring/tests/internal_encoding.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,38 @@ var_dump(mb_strlen("\xc3\xb6"));

?>
--EXPECTF--
Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(10) "ISO-8859-1"
int(2)

Deprecated: ini_set(): Use of mbstring.internal_encoding is deprecated in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"
int(1)

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"
int(1)

Deprecated: ini_set(): Use of mbstring.internal_encoding is deprecated in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(10) "ISO-8859-2"
int(2)

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"
int(1)

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(5) "UTF-8"
int(1)

Deprecated: ini_set(): Use of mbstring.internal_encoding is deprecated in %s on line %d

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
string(10) "ISO-8859-3"
int(2)
4 changes: 3 additions & 1 deletion ext/mbstring/tests/mb_chr.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ try {
}

?>
--EXPECT--
--EXPECTF--
bool(true)
bool(true)
bool(true)
Expand All @@ -56,4 +56,6 @@ mb_chr(): Argument #2 ($encoding) must be a valid encoding, "pass" given
mb_chr() does not support the "JIS" encoding
mb_chr() does not support the "CP50222" encoding
mb_chr() does not support the "UTF-7" encoding

Deprecated: Function mb_internal_encoding() is deprecated since 8.5, use internal_encoding INI settings instead in %s on line %d
mb_chr() does not support the "UTF-7" encoding
40 changes: 20 additions & 20 deletions ext/mbstring/tests/mb_decode_mimeheader_variation4.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,89 +8,89 @@ mbstring
// We convert runs of whitespace, including CR, LF, tab, and space, to a single space...
// but ONLY when that run of whitespace does not occur right in the middle between two
// valid MIME encoded words
mb_internal_encoding('UCS-2');
ini_set('internal_encoding', 'UCS-2');
var_dump(bin2hex(mb_decode_mimeheader("2,\rGCG\xb3GS")));

// We DO convert a run of whitespace to a single space at the very beginning of the input string,
// as long as it is followed by a non-whitespace character
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("\n8i")));

// But not if it is just a CR or LF at the end of the string
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("\r")));

// Not if it is a run of whitespace going right up to the end of the string
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("\n ")));

// Handle = which doesn't initiate a valid encoded word
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader(",\x13@=,")));

// Encoded word which should not be accepted
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?I?B??=")));

// Encoded word with invalid charset name, and input string ends with whitespace
// The old implementation of mb_decode_mimeheader would get 'stuck' on the invalid encoding name
// and could never get out of that state; it would not even try to interpret any other encoded words
// up to the end of the input string
mb_internal_encoding('ISO-8859-7');
ini_set('internal_encoding', 'ISO-8859-7');
var_dump(bin2hex(mb_decode_mimeheader("=?=\x20?=?R\xb7=?=\x20?\x8b\x00====?===??=\xc5UC-R\xb7=?=\x20?=?=====?=\x20?======?======?=\x20?======?===??=\xc5UC-KR\xb7=?=\x20?=?===?==?\x0a")));

// While the old implementation would generally trim off whitespace at the end of the input string,
// but there was a bug whereby it would not do this when the whitespace character was the 100th
// byte of an invalid charset name
mb_internal_encoding('UCS-2');
ini_set('internal_encoding', 'UCS-2');
var_dump(bin2hex(mb_decode_mimeheader("=?\xc2\x86tf7,U\x01\x00`@\x00\x04|\xf1D\x18\x00\x00\x00v\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xff\x13f7,U&\x00S\x01\x00\x17,D\xcb\xcb\xcb\xcb\xcb\xcb\xcb\x01\x00\x00\x14\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\xcb\x00\x11\x00\x00\x00\x00\x00\x00\x0a")));

// Empty encoded word
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?us?B?")));

// Encoded word with just one invalid Base64 byte
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?us?B?-")));

// Encoded word with an invalid Base64 byte followed by a valid Base64 byte
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?us?B?-s")));

// Empty encoded word with a ? which looks like it should be terminator, but = is missing
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?us?B??")));

// Encoded word with just one invalid Base64 byte, but this time properly terminated
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?us?B?\x00?=")));

// Invalid encoded word, followed immediately by valid encoded word
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?=?hz?b?")));

// Another example of invalid encoded word followed immediately by valid encoded word
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?==?hz?b?")));

// Yet another example
mb_internal_encoding('ASCII');
ini_set('internal_encoding', 'ASCII');
var_dump(bin2hex(mb_decode_mimeheader("=?,=?hz?b?")));

// In PHP 8.0-8.1 this would cause a crash
mb_internal_encoding('UUENCODE');
ini_set('internal_encoding', 'UUENCODE');
var_dump(bin2hex(mb_decode_mimeheader("")));

// The conversion filter for SJIS-Mobile#SOFTBANK did not work correctly when it was
// passed the last buffer of wchars without passing 'end' flag, then called one more
// time with an empty buffer and 'end' flag to finish up
mb_internal_encoding('SJIS-Mobile#SOFTBANK');
ini_set('internal_encoding', 'SJIS-Mobile#SOFTBANK');
var_dump(bin2hex(mb_decode_mimeheader("6")));

// Same for SJIS-Mobile#KDDI and SJIS-Mobile#DOCOMO
mb_internal_encoding('SJIS-Mobile#KDDI');
ini_set('internal_encoding', 'SJIS-Mobile#SOFTBANK');
var_dump(bin2hex(mb_decode_mimeheader("6")));
mb_internal_encoding('SJIS-Mobile#DOCOMO');
ini_set('internal_encoding', 'SJIS-Mobile#SOFTBANK');
var_dump(bin2hex(mb_decode_mimeheader("6")));

?>
Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/tests/mb_encode_mimeheader_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ foreach ($english as $lang => $input) {
var_dump(mb_encode_mimeheader($input, 'UTF-8', 'Q'));
}

mb_internal_encoding('utf-8');
ini_set('internal_encoding', 'utf-8');

foreach ($nonEnglish as $lang => $input) {
echo "\nLanguage: $lang\n";
Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/tests/mb_encode_mimeheader_basic2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $inputs = array('SJIS' => $sjis_string,
foreach ($inputs as $lang => $input) {
echo "\nLanguage: $lang\n";
echo "-- Base 64: --\n";
mb_internal_encoding($lang);
ini_set('internal_encoding', $lang);
$outEncoding = "UTF-8";
var_dump(mb_encode_mimeheader($input, $outEncoding, 'B'));
echo "-- Quoted-Printable --\n";
Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/tests/mb_encode_mimeheader_basic3.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $inputs = array('SJIS' => $sjis_string,
foreach ($inputs as $lang => $input) {
echo "\nLanguage: $lang\n";
echo "-- Base 64: --\n";
mb_internal_encoding($lang);
ini_set('internal_encoding', $lang);
$outEncoding = $lang;
var_dump(mb_encode_mimeheader($input, $outEncoding, 'B'));
echo "-- Quoted-Printable --\n";
Expand Down
Loading
Loading