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

1615 Commits

Author SHA1 Message Date
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
Niels Dossche 525aeff070 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17500: Segfault with requesting nodeName on nameless doctype
2025-01-17 19:37:14 +01:00
Niels Dossche 82d71a82aa Fix GH-17500: Segfault with requesting nodeName on nameless doctype
Closes GH-17344.
2025-01-17 19:36:47 +01:00
Niels Dossche 2952e164a9 Fix GH-17481: UTF-8 corruption in \Dom\HTMLDocument
We need to properly handle the case when we return from having too few
bytes, this needs to be handled separately because the while loop
otherwise just performs a partial byte copy.

Closes GH-17489.
2025-01-17 16:25:08 +01:00
Niels Dossche 21c170c75a Fix GH-17486: Incorrect error line numbers reported in Dom\HTMLDocument::createFromString
Closes GH-17491.
2025-01-17 16:24:28 +01:00
Niels Dossche ac266c9a05 Cherry-pick lexbor/lexbor@58c88147
See https://github.com/lexbor/lexbor/issues/261.
2025-01-16 19:22:25 +01:00
Niels Dossche 6d215981b6 Fix GH-17397: Assertion failure ext/dom/php_dom.c
The problem was that the property hash tables were not merging the
correct ones, a stupid typo (or caused by merging).

Closes GH-17406.
2025-01-08 19:45:40 +01:00
Niels Dossche 9d04d41eec Fix some emalloc() size mistakes
Fortunately, these only allocate too much memory and not too little.
Also just change it to `sizeof(*var)` everywhere to avoid this mistake
in the future.
2024-12-29 12:11:38 +01:00
Niels Dossche 956576b0b4 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17223: Memory leak in libxml encoding handling
2024-12-26 12:25:08 +01:00
Niels Dossche 7be950f3f6 Fix GH-17223: Memory leak in libxml encoding handling
This was a bug in both libxml and PHP.
We follow up with the same change as done in GNOME/libxml@b3871dd138.

Changing away from `xmlOutputBufferCreateFilenameDefault` is not
possible yet because this is a stable branch and would break BC.

Closes GH-17254.
2024-12-26 12:24:06 +01:00
Niels Dossche d2b6b64655 Fix DOM test on higher branches 2024-12-21 12:50:04 +01:00
Niels Dossche 62dc89d947 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-17224: UAF in importNode
2024-12-21 12:01:48 +01:00
Niels Dossche 61615d5673 Fix GH-17224: UAF in importNode
Wrong document pointer is used for the namespace copy.

Closes GH-17230.
2024-12-21 12:01:22 +01:00
Niels Dossche e247461881 Fix GH-17201: Dom\TokenList issues with interned string replace
If a bucket previously had a non-interned string, and is now replaced
with an interned string, then the type flags still incorrectly state
it's a non-interned string. This leads to the refcount being edited for
interned strings, which in turn can lead to a crash when protect_memory
is set.

Closes GH-17207.
2024-12-17 23:07:58 +01:00
Niels Dossche 4656c22526 Fix GH-17145: DOM memory leak
Because the use of RETURN instead of RETVAL, the freeing code could not
be executed. This only is triggerable if the content of the attribute is
mixed text and entities, so it wasn't noticed earlier.

Closes GH-17147.
2024-12-14 12:12:40 +01:00
Niels Dossche 901ebd1c1a Update HTML5 serializer comments 2024-12-11 19:48:47 +01:00
Niels Dossche d7a37cc9ad Add missing backslash for TokenList interfaces in stub (#17009)
Discovered while trying to generate class synopses.
2024-12-01 15:18:44 +01:00
Niels Dossche 52c7c74ebb Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-16906: Reloading document can cause UAF in iterator
2024-11-24 18:20:21 +01:00
Niels Dossche 9d39ff764e Fix GH-16906: Reloading document can cause UAF in iterator
Closes GH-16909.
2024-11-24 18:19:45 +01:00