1
0
mirror of https://github.com/php/php-src.git synced 2026-03-26 01:02:25 +01:00
Commit Graph

1269 Commits

Author SHA1 Message Date
Vinicius Dias
f1af7223f8 Fixing incorrect error message when passing null to join/implode's array parameter (#12683)
Closes GH-12682
2023-12-01 09:55:20 +00:00
Niels Dossche
9a973a3743 Optimize strcspn (#12594) 2023-11-04 13:54:30 +00:00
Ilija Tovilo
d35faecbf2 Split strtr zpp (#12583) 2023-11-01 13:08:06 +01:00
Ilija Tovilo
f39b5c4c25 Close PHP tags in tests
Closes GH-12422
2023-10-18 17:34:10 +02:00
Ilija Tovilo
b31a5b2731 Fix str_decrement() on "1"
Closes GH-12339
2023-10-02 16:42:04 +02:00
Jakub Zelenka
64ebadcac5 Fix GH-12151: str_getcsv ending with escape zero segfualt
Closes GH-12152
2023-09-08 10:58:55 +01:00
Jakub Zelenka
aff46d75e1 Fix GH-11982: str_getcsv returns null byte for unterminated quoted string
Closes GH-12047
2023-08-28 11:28:34 +01:00
Kamil Tekiela
649872f105 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix param name in implode() error message
2023-08-24 21:07:50 +01:00
Kamil Tekiela
ec82927d25 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix param name in implode() error message
2023-08-24 21:07:18 +01:00
Kamil Tekiela
b1ce1d1f21 Fix param name in implode() error message 2023-08-24 21:05:26 +01:00
HypeMC
f25474f7f2 Add before_needle argument to strrchr()
Closes GH-11430
2023-08-24 14:26:46 +01:00
Kamil Tekiela
f907a009f9 Align highlight_string|file with HTML standard and modern browsers
Closes GH-11913
2023-08-12 15:08:28 +01:00
George Peter Banyard
d8696f9216 [RFC] Path to Saner Increment/Decrement operators (#10358)
* Add behavioural tests for incdec operators

* Add support to ++/-- for objects castable to _IS_NUMBER

* Add str_increment() function

* Add str_decrement() function

RFC: https://wiki.php.net/rfc/saner-inc-dec-operators

Co-authored-by: Ilija Tovilo <ilija.tovilo@me.com>
Co-authored-by: Arnaud Le Blanc <arnaud.lb@gmail.com>
2023-07-17 15:51:24 +01:00
Niels Dossche
f8ecb80e84 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix undefined behaviour in unpack()
2023-03-28 22:48:21 +02:00
Niels Dossche
e9195b21cc Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix undefined behaviour in unpack()
2023-03-28 22:43:53 +02:00
Niels Dossche
87862835e2 Fix undefined behaviour in unpack()
atoi()'s return value is actually undefined when an underflow or
overflow occurs. For example on 32-bit on my system the overflow test
which inputs "h2147483648" results in repetitions==2147483647 and on
64-bit this gives repetitions==-2147483648. The reason the test works on
32-bit is because there's a second undefined behaviour problem:
in case 'h' when repetitions==2147483647, we add 1 and divide by 2.
This is signed-wrap undefined behaviour and accidentally triggers the
overflow check like we wanted to.

Avoid all this trouble and use strtol with explicit error checking.

This also fixes a semantic bug where repetitions==INT_MAX would result
in the overflow check to trigger, even though there is no overflow.

Closes GH-10943.
2023-03-28 22:43:27 +02:00
Niels Dossche
6ec69d727a Improve the warning message for unpack() in case not enough values were provided (#10949) 2023-03-27 00:04:42 +02:00
George Peter Banyard
524391bcf6 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fixed ValueError message in count_chars()
  Fixed ValueError message in substr_compare()
  The userland constants do not start with PHP_
2023-02-26 14:28:49 +00:00
George Peter Banyard
f440911057 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fixed ValueError message in count_chars()
  Fixed ValueError message in substr_compare()
  The userland constants do not start with PHP_
2023-02-26 14:28:22 +00:00
George Peter Banyard
adc5edd411 Fixed ValueError message in count_chars()
The value of the mode argument must be between 0 and 4 inclusive, not 1 and 4.
2023-02-26 14:27:46 +00:00
George Peter Banyard
2133970152 Fixed ValueError message in substr_compare()
It used some random argument name instead of
2023-02-26 14:25:02 +00:00
Alex Dowad
c02af98ae5 Use AVX2 to accelerate strto{upper,lower} (only on 'AVX2-native' builds for now)
On short strings, there is no difference in performance. However, for
strings around 10,000 bytes long, the AVX2-accelerated function is
about 55% faster than the SSE2-accelerated one.
2023-02-03 16:29:27 +02:00
George Peter Banyard
3fe8b090d3 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix incorrect check in zend_internal_call_should_throw()
  Fix incorrect check in cs_8559_5 in map_from_unicode()
  Fix incorrect page_size check
2023-01-25 00:12:32 +00:00
George Peter Banyard
0d9bf101c4 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix incorrect check in cs_8559_5 in map_from_unicode()
  Fix incorrect page_size check
2023-01-25 00:10:56 +00:00
Niels Dossche
a8c8fb2564 Fix incorrect check in cs_8559_5 in map_from_unicode()
The condition `code == 0x0450 || code == 0x045D` is always false because
of an incorrect range check on code.
According to the BMP coverage in the encoding spec for ISO-8859-5
(https://encoding.spec.whatwg.org/iso-8859-5-bmp.html) the range of
valid characters is 0x0401 - 0x045F (except for 0x040D, 0x0450, 0x045D).
The current check has an upper bound of 0x044F instead of 0x045F.
Fix this by changing the upper bound.

Closes GH-10399

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-25 00:08:28 +00:00
David Carlier
256a34ed15 strtok warns in case the string to split was not set.
Close GH-10016.
2023-01-23 12:13:49 +00:00
Máté Kocsis
7936c8085e Fix GH-8329 Print true/false instead of bool in error and debug messages (#8385) 2023-01-23 10:52:14 +01:00
Alex Dowad
0b7986f976 Tweak SSE2-accelerated strtoupper() and strtolower() for speed
I learned this trick for doing a faster bounds check with both upper
and lower bounds by reading a disassembler listing of optimized code
produced by GCC; instead of doing 2 compares to check the upper and the
lower bound, add an immediate value to shift the range you are testing
for to the far low or high end of the range of possible values for the
type in question, and then a single compare will do. Intstead of
compare + compare + AND, you just do ADD + compare.

From microbenchmarking on my development PC, this makes strtoupper()
about 10% faster on long strings (~10,000 bytes).
2023-01-20 08:21:45 +02:00
George Peter Banyard
c177ea91d4 Move http_build_query() tests to the HTTP test folder 2023-01-15 16:00:17 +00:00
George Peter Banyard
5624cbbed1 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix wrong flags check for compression method in phar_object.c
  Fix missing check for xmlTextWriterEndElement
  Fix substr_replace with slots in repl_ht being UNDEF
2023-01-15 15:43:57 +00:00
George Peter Banyard
ec377c687d Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix wrong flags check for compression method in phar_object.c
  Fix missing check for xmlTextWriterEndElement
  Fix substr_replace with slots in repl_ht being UNDEF
2023-01-15 15:43:34 +00:00
Niels Dossche
4bbbe6d652 Fix substr_replace with slots in repl_ht being UNDEF
The check that was supposed to check whether the array slot was UNDEF
was wrong and never triggered. This resulted in a replacement with the
empty string or the wrong string instead of the correct one. The correct
check pattern can be observed higher up in the function's code.

Closes GH-10323

Signed-off-by: George Peter Banyard <girgias@php.net>
2023-01-15 15:31:34 +00:00
George Peter Banyard
11f6022365 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-10187: Segfault in stripslashes() with arm64
  Fix memory leak in posix_ttyname()
2022-12-30 16:43:05 +00:00
George Peter Banyard
e6c9b176d4 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-10187: Segfault in stripslashes() with arm64
  Fix memory leak in posix_ttyname()
2022-12-30 16:42:45 +00:00
Niels Dossche
4c9375e504 Fix GH-10187: Segfault in stripslashes() with arm64
Closes GH-10188

Co-authored-by: todeveni <toni.viemero@iki.fi>
Signed-off-by: George Peter Banyard <girgias@php.net>
2022-12-30 16:40:56 +00:00
Tim Düsterhus
dd8de1e726 Promote unserialize() notices to warning (#9629)
* Unserialize: Migrate "Unexpected end of serialized data" to E_WARNING

* Unserialize: Migrate "Error at offset %d of %d bytes" to E_WARNING

* Unserialize: Migrate "%s is returned from __sleep() multiple times" to E_WARNING

* Add NEWS for “Promote unserialize() notices to warning”
2022-11-15 19:36:38 +01:00
Michael Voříšek
60189aa96a Skip locale tests /w musl libc (#9141) 2022-07-25 23:56:14 +01:00
Michael Voříšek
e80925445c Fix GH-8924 str_split of empty string must return empty array
Closes #8945.
2022-07-08 15:49:45 +01:00
Rowan Tommins
d9f3ca705c Add deprecation notices to utf8_encode and utf8_decode
Implements initial stage of accepted RFC to remove them:
https://wiki.php.net/rfc/remove_utf8_decode_and_utf8_encode

Tests relating to SOAP and htmlspecialchars seem to have been
using this entirely unnecessarily, so have been fixed.

Closes GH-8726.
2022-06-12 13:37:23 +02:00
Max Kellermann
c1a06704da Add ZEND_THREEWAY_COMPARE() macro to fix casting underflowed unsigned to signed (#8220)
Casting a huge unsigned value to signed is implementation-defined
behavior in C.  By introducing the ZEND_THREEWAY_COMPARE() macro, we
can sidestep this integer overflow/underflow/casting problem.
2022-06-08 13:24:18 +01:00
Ilija Tovilo
9a90bd7054 Deprecate ${} string interpolation
https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation
2022-05-05 10:14:56 +02:00
Remi Collet
e31c54d025 fix GH-7899 Regression in unpack for negative int value 2022-01-13 11:47:19 +01:00
Remi Collet
d5b6c0de06 Merge branch 'PHP-8.1'
* PHP-8.1:
  fix GH-7899 Regression in unpack for negative int value
  Fix ext/zend_test/tests/observer_bug81430_2.phpt failure
  JIT: Fix incorrect flag check
2022-01-13 11:45:47 +01:00
Remi Collet
524ce90418 fix GH-7899 Regression in unpack for negative int value 2022-01-13 11:44:34 +01:00
Christoph M. Becker
c5c66bd8ec Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix chunk_split_variation*_32bit.phpt for Windows
2021-12-26 12:07:44 +01:00
Christoph M. Becker
9e4437f8c6 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix chunk_split_variation*_32bit.phpt for Windows
2021-12-26 12:07:07 +01:00
Christoph M. Becker
b4ba65dd9d Fix chunk_split_variation*_32bit.phpt for Windows
Both tests fail on Windows for slightly different reasons, what appears
to be legit, and as such we fix the test expectations.

Closes GH-7830.
2021-12-26 12:05:52 +01:00
Tim Starling
8eee0d6130 Make strtolower() and strtoupper() do ASCII case conversion (#7506)
Implement RFC https://wiki.php.net/rfc/strtolower-ascii
2021-12-15 08:38:35 -05:00
Nikita Popov
23e6856e41 Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix bug #69751
2021-09-29 12:21:56 +02:00
Nikita Popov
3dfdf968e1 Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix bug #69751
2021-09-29 12:21:49 +02:00