1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 17:08:14 +02:00
Commit Graph

1633 Commits

Author SHA1 Message Date
Niels Dossche 3023b29a11 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19612: Mitigate libxml2 tree dictionary bug
2025-09-03 21:58:16 +02:00
Niels Dossche 080fd14458 Fix GH-19612: Mitigate libxml2 tree dictionary bug
This code is very similar to code on PHP 8.4 and higher, but the
mitigation is extended to entity references and to attribute children.

Closes GH-19620.
2025-09-03 21:52:48 +02:00
Niels Dossche 3690df022b Fix Windows build 2025-08-25 00:23:09 +02:00
Niels Dossche c66af62511 Sync lexbor with master on PHP 8.4 2025-08-25 00:06:18 +02:00
Niels Dossche 91665eaa63 Backport Lexbor changes to 8.4 2025-08-10 14:17:19 +02:00
Niels Dossche 1d5089e574 Fix GH-18979: DOM\XMLDocument::createComment() triggers undefined behavior with null byte
Closes GH-18983.
2025-07-01 18:51:21 +02:00
Gina Peter Banyard 940441106d ext/dom: Fix new MSVC compiler warning
Closes GH-18889
2025-06-20 19:08:33 +02:00
Niels Dossche 111072a9f0 Fix GH-18744: PHP 8.4 classList works not correctly if copy HTMLElement by clone keyword.
The $classList property is special in the sense that it's a cached
object instance per (HTML)Element instance. The reason for this design
is because it has the [[SameObject]] IDL attribute.
Cloning in PHP also clones the properties, so it also clones the cached
instance. To solve this, we undo this by resetting the backing storage.

Closes GH-18749.
2025-06-04 18:59:05 +02:00
Niels Dossche 9e9db0b22f Update Lexbor patches for non-string attribute
This should fix the final sub-issue of GH-17687.

Closes GH-18691.
2025-05-28 23:34:08 +02:00
Niels Dossche 40e667280b Fix GH-18597: Heap-buffer-overflow in zend_alloc.c when assigning string with UTF-8 bytes
xmlSave() also can flush in some cases. When the encoding is not
available this can fail for short inputs, resulting in an empty string
which is interned but then wrongly tagged by RETURN_NEW_STR.
Fix this by checking the error condition and switching to RETURN_STR for
defense-in-depth.

This issue also exists on 8.3, but does not crash; however, due to the
different API usage internally I cannot easily fix it on 8.3. There it
gives a partial output.

Closes GH-18606.
2025-05-20 21:32:17 +02:00
Niels Dossche 9bf140afb4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix deprecation warning for libxml SAX header (#18594)
2025-05-19 19:11:22 +02:00
Niels Dossche 92a0cc7d94 Fix deprecation warning for libxml SAX header (#18594)
This header is deprecated, but fortunately it isn't actually used.
2025-05-19 19:10:27 +02:00
Niels Dossche dbc7c5f34a Backport lexbor/lexbor@814e0bce97 (#18574)
Co-authored-by: Alexander Borisov <lex.borisov@gmail.com>
2025-05-16 20:27:56 +02:00
Niels Dossche 42ad1c64bf Backport lexbor/lexbor#274
Co-authored-by: Alex Peattie <alexpeattie@gmail.com>

Closes GH-18490.
2025-05-04 12:57:54 +02:00
Niels Dossche 94b58239e8 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix DOM tests for upcoming libxml2 serializer changes
2025-04-23 18:30:00 +02:00
Niels Dossche d6e70e7053 Fix DOM tests for upcoming libxml2 serializer changes
DOM HTML serializer will be closer compliant to HTML5 in the next
libxml2 version, so the tests need to be adapted.
Ref: https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/309

Closes GH-18406.
2025-04-23 18:29:44 +02:00
Niels Dossche a019fbd970 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-18309: ipv6 filter integer overflow
  Fix GH-18304: Changing the properties of a DateInterval through dynamic properties triggers a SegFault
2025-04-11 23:36:12 +02:00
Niels Dossche ba0853888d Fix GH-18304: Changing the properties of a DateInterval through dynamic properties triggers a SegFault
For dynamic fetches the cache_slot will be NULL, so we have to check for
that when resetting the cache. For zip and xmlreader this couldn't
easily be tested because of a lack of writable properties.

Closes GH-18307.
2025-04-11 23:33:58 +02:00
Niels Dossche 2c45d67ad3 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix xinclude destruction of live attributes
2025-03-18 22:04:13 +01:00
Niels Dossche d9329b1522 Fix xinclude destruction of live attributes
Follow-up for GH-17847 but now for attributes.

Closes GH-18100.
2025-03-18 22:01:56 +01:00
Niels Dossche 647baec5a4 Fix GH-18090: DOM: Svg attributes and tag names are being lowercased
Closes GH-18091.
2025-03-17 19:45:50 +01:00
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
Tim Düsterhus b6004a043c Fix GHSA-p3x9-6h7p-cgfc: libxml streams wrong content-type on redirect
libxml streams use wrong content-type header when requesting a
redirected resource.
2025-03-11 21:50:17 +01:00
Niels Dossche 09189026e6 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix test GH-16535 for libxml2 2.14
  Fix tests for libxml2 2.14
2025-03-10 20:23:43 +01:00
Niels Dossche 1befdce0e6 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Fix test GH-16535 for libxml2 2.14
  Fix tests for libxml2 2.14
2025-03-10 20:23:36 +01:00
Niels Dossche b5471300d2 Fix test GH-16535 for libxml2 2.14 2025-03-10 20:23:23 +01:00
Niels Dossche 239b01db7c Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix tests for libxml2 2.14
2025-03-10 20:22:27 +01:00
Niels Dossche f209eb448e Fix tests for libxml2 2.14
See GH-18009.
2025-03-10 20:22:11 +01:00
Niels Dossche aa6e58f82a Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix weird unpack behaviour in DOM
  Fix GH-17989: mb_output_handler crash with unset http_output_conv_mimetypes
2025-03-09 11:21:27 +01:00
Niels Dossche 9be9f70caa Fix weird unpack behaviour in DOM
Engine pitfall: the iter index is only updated by foreach opcodes, so
the existing code that used it as an index for the nodes w.r.t. the
start did not work properly. Fix it by using our own counter.

Closes GH-18004.
2025-03-09 11:17:03 +01:00
Niels Dossche 8950c241b3 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix uninitialized memory accesses in DOM iterator
2025-03-08 11:12:34 +01:00
Niels Dossche 2634622d3d Fix uninitialized memory accesses in DOM iterator 2025-03-08 11:12:24 +01:00
Niels Dossche 6083dc09a3 Fix GH-17991: Assertion failure dom_attr_value_write
Closes GH-17995.
2025-03-07 22:43:38 +01:00
Niels Dossche ee4a9a4a7c Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17736: Assertion failure zend_reference_destroy()
2025-03-02 22:37:07 +01:00
Niels Dossche ce8ab5f16a Fix GH-17736: Assertion failure zend_reference_destroy()
The cache slot for FETCH_OBJ_W in function `test` is primed with the
class for C. The next call uses a simplexml instance and reuses the same
cache slot. simplexml's get_property_ptr handler does not use the cache
slot, so the old values remain in the cache slot. When
`zend_handle_fetch_obj_flags` is called this is not guarded by a check
for the class entry. So we end up using the prop_info from the property
C::$a instead of the simplexml property.

This patch adds a reset to the cache slots in the property address fetch
code and also in the extensions with a non-standard reference handler.
This keeps the run time cache consistent and avoids the issue without
complicating the fast paths.

Closes GH-17739.
2025-03-02 22:33:32 +01:00
Niels Dossche 7974c62873 Fix using Dom\Node with Dom\XPath callbacks
This code was introduced when the Dom\Node and DOMNode classes were
still aliases, so the type check was never updated.
We fix this by checking if the doc pointer follows the spec and pick the
right node CE based on that.

Closes GH-17888.
2025-02-22 16:00:39 +01:00
Niels Dossche be3d128632 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17847: xinclude destroys live node
2025-02-21 22:27:53 +01:00
Niels Dossche 9becccef17 Fix GH-17847: xinclude destroys live node
dom_xinclude_strip_fallback_references() now also takes into account
xi:include nodes children. This now subsumes all work done normally by
the old start/end node removal, so we can remove that code and start
using XML_PARSE_NOXINCNODE.

Closes GH-17878.
2025-02-21 22:24:44 +01:00
Niels Dossche 74df3e0404 Fix lowercase HTML attribute exceptions
Closes GH-17815.
2025-02-17 19:31:50 +01:00
Niels Dossche 3a4a320386 Fix GH-17802: \Dom\HTMLDocument querySelector attribute name is case sensitive in HTML
According to https://html.spec.whatwg.org/#case-sensitivity-of-selectors,
the CSS selector attribute name must be converted to lowercase in HTML elements,
and then compared case-sensitive to the attribute name in the element.
We implement this not by doing the explicit conversion, but by a manual
loop using a function that first converts the rhs characters to
lowercase and keeps the lhs characters the same, achieving the same
effect.
2025-02-17 19:31:23 +01:00
Niels Dossche 81803b9b09 Fix potential read of uninitialized padding data in DOM (#17628)
The fix for GH-17481 introduced a regression that can cause the read of
uninitialized padding data when going over a chunk boundary during HTML
parsing of UTF-8.
The wrong offset was computed with respect to the input buffer, the
length of the error-corrected UTF-8 code point is not necessarily the
same as the input code point length.
This was not noticed because no CI jobs run with Valgrind nor I do it
regularly, and ASAN doesn't catch uninitialized accesses.
2025-01-30 11:26:58 -04:00
Niels Dossche 359eb30351 Fix GH-17609: Typo in error message: Dom\NO_DEFAULT_NS instead of Dom\HTML_NO_DEFAULT_NS 2025-01-28 19:30:25 +01:00
Niels Dossche fc7c353519 Fix GH-17572: getElementsByTagName returns collections with tagName-based indexing, causing loss of elements when converted to arrays
Only (dtd) named node maps should have string-based indexing.
The ce check is fragile, just check for the presence of an xml hash
table.

Closes GH-17580.
2025-01-26 16:21:54 +01:00
Niels Dossche 22704af4b8 Cherry-pick lexbor/lexbor@f94d97a3
Co-authored-by: Alexander Borisov <lex.borisov@gmail.com>
2025-01-19 11:50:56 +01:00
Niels Dossche 0b04061e71 NEWS for GH-17485
Fixes GH-17485.
2025-01-17 19:43:08 +01:00
Niels Dossche d0981864eb Cherry-pick lexbor/lexbor@e58e1e8c
Co-authored-by: Alexander Borisov <lex.borisov@gmail.com>
2025-01-17 19:39:58 +01:00
Niels Dossche a928b66447 Cherry-pick lexbor/lexbor@ae97abfb
Co-authored-by: Alexander Borisov <lex.borisov@gmail.com>
2025-01-17 19:39:12 +01:00
Niels Dossche 4531292ad2 Cherry-pick lexbor/lexbor@e39083b0
Co-authored-by: Alexander Borisov <lex.borisov@gmail.com>
2025-01-17 19:39:12 +01:00