mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
strtok warns in case the string to split was not set.
Close GH-10016.
This commit is contained in:
parent
7936c8085e
commit
256a34ed15
7 changed files with 94 additions and 5 deletions
2
NEWS
2
NEWS
|
@ -99,6 +99,8 @@ PHP NEWS
|
||||||
- Standard:
|
- Standard:
|
||||||
. E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla)
|
. E_NOTICEs emitted by unserialize() have been promoted to E_WARNING. (timwolla)
|
||||||
. Make array_pad's $length warning less confusing. (nielsdos)
|
. Make array_pad's $length warning less confusing. (nielsdos)
|
||||||
|
. E_WARNING emitted by strtok in the caase both arguments are not provided when
|
||||||
|
starting tokenisation. (David Carlier)
|
||||||
|
|
||||||
- Streams:
|
- Streams:
|
||||||
. Fixed bug #51056: blocking fread() will block even if data is available.
|
. Fixed bug #51056: blocking fread() will block even if data is available.
|
||||||
|
|
|
@ -68,6 +68,7 @@ PHP 8.3 UPGRADE NOTES
|
||||||
. array_pad() is now only limited by the maximum number of elements an array
|
. array_pad() is now only limited by the maximum number of elements an array
|
||||||
can have. Before, it was only possible to add at most 1048576 elements at a
|
can have. Before, it was only possible to add at most 1048576 elements at a
|
||||||
time.
|
time.
|
||||||
|
. strtok() raises a warninin the case token is not provided when starting tokenization.
|
||||||
|
|
||||||
========================================
|
========================================
|
||||||
6. New Functions
|
6. New Functions
|
||||||
|
|
|
@ -1080,7 +1080,7 @@ PHP_FUNCTION(strtok)
|
||||||
|
|
||||||
if (!BG(strtok_string)) {
|
if (!BG(strtok_string)) {
|
||||||
/* String to tokenize not set. */
|
/* String to tokenize not set. */
|
||||||
// TODO: Should this warn?
|
php_error_docref(NULL, E_WARNING, "Both arguments must be provided when starting tokenization");
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ foreach($heredoc_strings as $string) {
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
*** Testing strtok() : with heredoc strings ***
|
*** Testing strtok() : with heredoc strings ***
|
||||||
|
|
||||||
--- Iteration 1 ---
|
--- Iteration 1 ---
|
||||||
|
@ -80,15 +80,35 @@ bool(false)
|
||||||
|
|
||||||
--- Iteration 2 ---
|
--- Iteration 2 ---
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--- Iteration 3 ---
|
--- Iteration 3 ---
|
||||||
|
@ -137,9 +157,19 @@ string(3) "rld"
|
||||||
string(4) "hell"
|
string(4) "hell"
|
||||||
string(4) "hell"
|
string(4) "hell"
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
Done
|
Done
|
||||||
|
|
|
@ -36,15 +36,25 @@ foreach( $strings_with_nulls as $string ) {
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
*** Testing strtok() : with embedded nulls in the strings ***
|
*** Testing strtok() : with embedded nulls in the strings ***
|
||||||
|
|
||||||
--- Iteration 1 ---
|
--- Iteration 1 ---
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--- Iteration 2 ---
|
--- Iteration 2 ---
|
||||||
|
@ -82,9 +92,17 @@ bool(false)
|
||||||
--- Iteration 6 ---
|
--- Iteration 6 ---
|
||||||
string(11) "hello world"
|
string(11) "hello world"
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--- Iteration 7 ---
|
--- Iteration 7 ---
|
||||||
|
|
|
@ -52,7 +52,7 @@ foreach( $string_array as $string ) {
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
*** Testing strtok() : with miscellaneous inputs ***
|
*** Testing strtok() : with miscellaneous inputs ***
|
||||||
|
|
||||||
--- Iteration 1 ---
|
--- Iteration 1 ---
|
||||||
|
@ -65,10 +65,20 @@ bool(false)
|
||||||
|
|
||||||
--- Iteration 2 ---
|
--- Iteration 2 ---
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--- Iteration 3 ---
|
--- Iteration 3 ---
|
||||||
|
@ -113,18 +123,38 @@ bool(false)
|
||||||
|
|
||||||
--- Iteration 8 ---
|
--- Iteration 8 ---
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--- Iteration 9 ---
|
--- Iteration 9 ---
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
--- Iteration 10 ---
|
--- Iteration 10 ---
|
||||||
|
|
|
@ -42,7 +42,7 @@ foreach( $string_array as $string ) {
|
||||||
|
|
||||||
echo "Done\n";
|
echo "Done\n";
|
||||||
?>
|
?>
|
||||||
--EXPECT--
|
--EXPECTF--
|
||||||
*** Testing strtok() : with invalid escape sequences in token ***
|
*** Testing strtok() : with invalid escape sequences in token ***
|
||||||
|
|
||||||
--- Iteration 1 ---
|
--- Iteration 1 ---
|
||||||
|
@ -69,6 +69,8 @@ bool(false)
|
||||||
string(1) " "
|
string(1) " "
|
||||||
string(1) "r"
|
string(1) "r"
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,11 +93,15 @@ bool(false)
|
||||||
string(5) "hello"
|
string(5) "hello"
|
||||||
string(6) " world"
|
string(6) " world"
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
string(1) " "
|
string(1) " "
|
||||||
string(1) "r"
|
string(1) "r"
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
|
||||||
|
@ -113,6 +119,8 @@ bool(false)
|
||||||
string(6) "hello\"
|
string(6) "hello\"
|
||||||
string(6) " world"
|
string(6) " world"
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
|
Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d
|
||||||
bool(false)
|
bool(false)
|
||||||
|
|
||||||
string(1) "/"
|
string(1) "/"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue