Commit graph

181 commits

Author SHA1 Message Date
Jakub Zelenka
6976fb6ba7
Merge branch 'PHP-8.3' into PHP-8.4 2025-03-11 22:23:09 +01:00
Jakub Zelenka
acf2f4988a
Merge branch 'PHP-8.2' into PHP-8.3 2025-03-11 22:09:00 +01:00
Jakub Zelenka
4af1830356
Merge branch 'PHP-8.1' into PHP-8.2 2025-03-11 21:57:33 +01:00
Niels Dossche
0e715e71d9
Fix GHSA-wg4p-4hqh-c3g9 2025-03-11 21:50:17 +01:00
Niels Dossche
575ee23bd9
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17187: unreachable program point in zend_hash
2024-12-27 15:54:37 +01:00
Niels Dossche
b621b3a00f
Fix GH-17187: unreachable program point in zend_hash
A bunch of different issues:
1) The referenced value is copied without incrementing the refcount.
   The reason the refcount isn't incremented is because otherwise
   the array modifications would violate the RC1 constraints.
   Solve this by copying the reference itself instead and always
   read the referenced value.
2) No type checks on the array data, so malicious scripts could
   cause type confusion bugs.
3) Potential overflow when the arrays resize and we access ctag.

Closes GH-17205.
2024-12-27 15:51:17 +01:00
Niels Dossche
14c107371c Backport 061058a9: Test fixes for libxml2 2.12.0 2024-10-12 15:12:40 +02:00
Niels Dossche
e7b022ea17
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
  Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
2024-09-13 20:02:00 +02:00
Niels Dossche
6c82ca2182
Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
Upon unwinding from an exception, the parser state is not stable, we
should not continue updating the values if an exception was thrown.

Closes GH-15879.
2024-09-13 20:01:44 +02:00
Niels Dossche
ac8db36543
Fix GH-15868: Assertion failure in xml_parse_into_struct after exception
Upon unwinding from an exception, the parser state is not stable, we
should not continue updating the values if an exception was thrown.

Closes GH-15879.
2024-09-13 19:59:41 +02:00
Gina Peter Bnayard
caae950ff7 ext/xml: Add an explicit test case about unsetting a handler with empty string 2024-08-11 15:00:27 +02:00
Gina Peter Banyard
25b4696530
ext/xml: Deprecate xml_set_object() and passing non-callable strings as handlers (#15293) 2024-08-08 23:37:49 +01:00
Niels Dossche
19358d638b Stop using reserved names 2024-07-06 13:49:45 -07:00
Niels Dossche
b41e90c6f9
Fix bug #81481 (xml_get_current_byte_index limited to 32-bit numbers on 64-bit builds) (#14845)
The return value is long in both expat and expat2 (with XML_LARGE_SIZE
not set).
2024-07-06 18:34:17 +02:00
Niels Dossche
b418d19c42
[ci skip] Make test more robust 2024-07-06 14:46:07 +02:00
Niels Dossche
fff206ba1e
Merge branch 'PHP-8.3'
* PHP-8.3:
  [ci skip] Test is for libxml only
2024-07-06 14:42:05 +02:00
Niels Dossche
459d79db95
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] Test is for libxml only
2024-07-06 14:41:56 +02:00
Niels Dossche
0b6289dab8
[ci skip] Test is for libxml only 2024-07-06 14:41:44 +02:00
Niels Dossche
f98aa06c68
Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-14834: Error installing PHP when --with-pear is used
2024-07-06 13:52:42 +02:00
Niels Dossche
9a337a85bf
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-14834: Error installing PHP when --with-pear is used
2024-07-06 13:52:34 +02:00
Niels Dossche
67259e451d
Fix GH-14834: Error installing PHP when --with-pear is used
libxml2 2.13 makes changes to how the parsing state is set, update our
code accordingly. In particular, it started reporting entities within
attributes, while it should only report entities inside text nodes.

Closes GH-14837.
2024-07-06 13:52:02 +02:00
David CARLIER
8eb0889d90
Fix GH-14637: memory leak after failed heap allocation due to mem limit. (#14641) 2024-06-23 21:43:02 +01:00
Niels Dossche
234b3cb241
Fix GH-14124: Segmentation fault on unknown address 0x0001ffff8041 with XML extension under certain memory limit (#14126)
The ltags were not initialized, so when an OOM happens before the new value is written, uninitialized data is used.
2024-05-04 13:57:50 +02:00
Tim Düsterhus
08b2ab22f4
Include the source location in Closure names (#13550)
* Include the source location in Closure names

This change makes stack traces involving Closures, especially multiple
different Closures, much more useful, because it's more easily visible *which*
closure was called for a given stack frame.

The implementation is similar to that of anonymous classes which already
include the file name and line number within their generated classname.

* Update scripts/dev/bless_tests.php for closure naming

* Adjust existing tests for closure naming

* Adjust tests for closure naming that were not caught locally

* Drop the namespace from closure names

This is redundant with the included filename.

* Include filename and line number as separate keys in Closure debug info

* Fix test

* Fix test

* Include the surrounding class and function name in closure names

* Fix test

* Relax test expecations

* Fix tests after merge

* NEWS / UPGRADING
2024-04-12 18:21:13 +02:00
Niels Dossche
4799321740 Merge branch 'PHP-8.3'
* PHP-8.3:
  Fix GH-13517: Multiple test failures when building with --with-expat
2024-02-27 21:49:47 +01:00
Niels Dossche
8bb2a15d01 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix GH-13517: Multiple test failures when building with --with-expat
2024-02-27 21:49:39 +01:00
Niels Dossche
552ea62e1f Fix GH-13517: Multiple test failures when building with --with-expat
The reflection failure is because the XML extension is used to check the
module dependency information, but that extension can be configured to
not depend on ext/libxml, resulting in a different output. The solution
is to check another extension instead.

The test failures in ext/xml/tests are because of different behaviour
between libxml2 and Expat error handling. These are expected differences
and the solution is to split the tests.

Closes GH-13522.
2024-02-27 21:49:01 +01:00
Niels Dossche
5be5a3dfdb Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Test fixes for libxml2 2.12.0
2023-11-29 20:53:13 +01:00
Niels Dossche
061058a9b1 Test fixes for libxml2 2.12.0 2023-11-29 20:52:01 +01:00
Niels Dossche
ae83d6ab07
Fix issues related to libxml2 2.12.0 (#12802)
* Avoid passing NULL to xmlSwitchToEncoding

This otherwise switches to UTF-8 on libxml2 2.12.0

* Split tests for different error reporting behaviour in libxml2 2.12.0

* Avoid deprecation warnings for libxml2 2.12.0

We can't fully get rid of the parser globals as there are still APIs
that implicitly use them.

* Temporarily disable part of test for libxml 2.12.0 regression

See https://gitlab.gnome.org/GNOME/libxml2/-/issues/634

* Review fixes

* [ci skip] Update test description
2023-11-29 20:46:35 +01:00
Niels Dossche
98b08c52db
Implement request #68325: parse huge option for xml_parser_create (#12256) 2023-10-22 16:44:49 +02:00
George Peter Banyard
0e5d654409
ext/xml: Refactor extension to use FCC instead of zvals for handlers (#12340)
To get proper errors and sensible behaviour, as the current behaviour is somewhat insane and part of it should be axed ASAP.

The behaviour is mostly intact with some minor BC breaks which are mentioned in UPGRADING.

Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2023-10-20 13:14:55 +01:00
Niels Dossche
2bbe4fda75 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix memory leak when calling xml_parse_into_struct() twice
  Fix return type of stub of xml_parse_into_struct()
2023-09-21 19:52:21 +02:00
Niels Dossche
2aea9be3ea Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix memory leak when calling xml_parse_into_struct() twice
  Fix return type of stub of xml_parse_into_struct()
2023-09-21 19:51:14 +02:00
Niels Dossche
30f26b587a Fix memory leak when calling xml_parse_into_struct() twice
Closes GH-12254.
2023-09-21 19:49:46 +02:00
Niels Dossche
82b05373b1 Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11160: Few tests failed building with new libxml 2.11.0
2023-05-06 23:15:57 +02:00
Niels Dossche
dc1a70c244 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11160: Few tests failed building with new libxml 2.11.0
2023-05-06 23:10:58 +02:00
Niels Dossche
7c0dfc5cf5 Fix GH-11160: Few tests failed building with new libxml 2.11.0
It's possible to categorise the failures into 2 categories:
  - Changed error message. In this case we either duplicate the test and
    modify the error message. Or if the change in error message is
    small, we use the EXPECTF matchers to make the test compatible with both
    old and new versions of libxml2.
  - Missing warnings. This is caused by a change in libxml2 where the
    parser started using SAX APIs internally [1]. In this case the
    error_type passed to php_libxml_internal_error_handler() changed from
    PHP_LIBXML_ERROR to PHP_LIBXML_CTX_WARNING because it internally
    started to use the SAX handlers instead of the generic handlers.
    However, for the SAX handlers the current input stack is empty, so
    nothing is actually printed. I fixed this by falling back to a
    regular warning without a filename & line number reference, which
    mimicks the old behaviour. Furthermore, this change now also shows
    an additional warning in a test which was previously hidden.

[1] 9a82b94a94

Closes GH-11162.
2023-05-06 23:10:07 +02:00
George Peter Banyard
81e59c6497
Improve handling of XML options
Mark boolean options as such
Warn on invalid types
Stubs info

Closes GH-10675
2023-02-26 14:34:39 +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
6a5b3f0ff9
The userland constants do not start with PHP_ 2023-02-26 14:18:12 +00:00
Christoph M. Becker
3214d84c34
Merge branch 'PHP-8.1'
* PHP-8.1:
  Fix #70962: XML_OPTION_SKIP_WHITE strips embedded whitespace
2021-09-16 12:44:13 +02:00
Christoph M. Becker
cc5ec597b7
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0:
  Fix #70962: XML_OPTION_SKIP_WHITE strips embedded whitespace
2021-09-16 12:42:07 +02:00
Christoph M. Becker
f55d78e817
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #70962: XML_OPTION_SKIP_WHITE strips embedded whitespace
2021-09-16 12:06:36 +02:00
Aliaksandr Bystry
a9661a5293
Fix #70962: XML_OPTION_SKIP_WHITE strips embedded whitespace
We must never strip embedded whitespace; we only need to skip values
when that option is set, and make sure that we keep BC regarding the
different behavior for "cdata" and "complete" elements (for the former,
the whole element is skipped; for the latter only the "value" key).

We also fix erroneous `int` types which should actually be `size_t`.

Co-authored-by: Christoph M. Becker <cmbecker69@gmx.de>

Closes GH-7493.
2021-09-16 12:00:28 +02:00
Nikita Popov
485d3acfe6 Make zend_call_function() failure handling consistent
This API had rather peculiar behavior in case the provided function
is not callable. For some types of failures, it would silently
return FAILURE (e.g. a function does not exist), while for others
(e.g. a class does not exist) it would generate a warning. Depending
on what the calling code does, this can either result in silent
failure or duplicate errors.

This commit switches the contract such that zend_call_function()
always (*) succeeds, though that success might be in the form of
throwing an exception. Calling a non-callable will now consistently
throw an exception.

There are some rare callers that do want to ignore missing methods,
for legacy APIs that are specific with optional methods. For these
use cases a new zend_call_method_if_exists() API is provided.

Calling code generally does not need to explicitly check for and
report zend_call_function() failures -- it can rely on
zend_call_function() having already done so. However, existing
code that does check for failure should continue to work fine.

(*) The only exception to this is if EG(active) being false during
late engine shutdown. This is not relevant to most code, but code
running in destructors and similar may need to be aware of the
possibility.
2021-09-01 16:09:23 +02:00
Christoph M. Becker
6db4b972d0
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix return value of xml_parse(_into_struct) for recursive parsing
2021-08-13 19:01:19 +02:00
Christoph M. Becker
15e5cf856a
Fix return value of xml_parse(_into_struct) for recursive parsing
As of PHP 8.0.0, these functions are supposed to return int, so we
cannot return `false`.  Since calling the parser recursively is a
programmer error, we throw an `Error` in this case.

Cf. <https://github.com/php/php-src/pull/7363>.
2021-08-13 19:00:13 +02:00
Christoph M. Becker
0f1bf4bbd7
Merge branch 'PHP-8.0'
* PHP-8.0:
  Fix #81351: xml_parse may fail, but has no error code
2021-08-13 17:40:32 +02:00
Christoph M. Becker
2c6177a4a8
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4:
  Fix #81351: xml_parse may fail, but has no error code
2021-08-13 17:37:36 +02:00