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

317 Commits

Author SHA1 Message Date
Niels Dossche 3cb7d1bd8a Remove custom UTF-8 check function from ext/libxml
This was originally introduced as a workaround for a libxml2 bug [1].
This bug has been fixed for more than a decade [2], and we can use the
libxml2 API again. We bumped our version requirement for libxml2 beyond
that in 7.4 [3].

[1] 7e53511ec8
[2] https://github.com/GNOME/libxml2/commit/3ffe90ea1cbd4fd8eb2eb162d7940a445f1455d6
[3] https://github.com/php/php-src/commit/74235ca5f3fae3325175cf0e68cd7e28c86e1378

Closes GH-18706.
2025-05-30 10:40:23 +02:00
Niels Dossche efaae93e48 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-18597: Heap-buffer-overflow in zend_alloc.c when assigning string with UTF-8 bytes
2025-05-20 21:32:27 +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
Gina Peter Banyard 3932d9b660 ext/libxml: Get rid of useless php_libxml_func_handler abstraction 2025-04-26 13:57:17 +01:00
Gina Peter Banyard dc036016a3 ext/libxml: Minor code nits 2025-04-26 13:57:17 +01:00
Gina Peter Banyard c5aa03c8b9 ext/libxml: Use bool type instead of int type 2025-04-26 13:57:17 +01:00
Gina Peter Banyard 1f1cd5c4bc ext/libxml: Add some const qualifiers 2025-04-26 13:57:17 +01:00
Gina Peter Banyard e59c7f887b ext/libxml: Reduce scope of variables 2025-04-26 13:57:17 +01:00
Gina Peter Banyard 213949dc34 Merge branch 'PHP-8.4'
* PHP-8.4:
  ext/libxml: Fixed custom external entity loader returning an invalid resource leading to a confusing TypeError message
2025-04-07 13:01:52 +01:00
Gina Peter Banyard 1e9e397122 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/libxml: Fixed custom external entity loader returning an invalid resource leading to a confusing TypeError message
2025-04-07 12:59:57 +01:00
Gina Peter Banyard 61f704f269 ext/libxml: Fixed custom external entity loader returning an invalid resource leading to a confusing TypeError message
Closes GH-18096
2025-04-07 12:58:52 +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
Christoph M. Becker aa76127d01 Address more Clang warnings (GH-17506)
We prefer clean solutions (such as declaring the proper type in the
first place, or introducing a portable format specifier) where easily
possible, but resort to casts otherwise.

We also port https://github.com/libgd/libgd/commit/f1480ab14bd5e2e4b4d83d8f3e64e786aa810637.
2025-01-21 20:05:29 +01:00
Niels Dossche 466c8b0e03 Merge branch 'PHP-8.4'
* PHP-8.4:
  Fix GH-17257: UBSAN warning in ext/opcache/jit/zend_jit_vm_helpers.c
  Fix GH-17223: Memory leak in libxml encoding handling
2024-12-26 12:26:59 +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 bc4fa01de7 Get rid of reserved name usage in ext/libxml (#16707)
Names starting with an _ are reserved in C.
2024-11-06 17:47:48 +01:00
Niels Dossche 6366da48ec Use unsigned int for the reference count APIs in ext/libxml (#16706)
Also removes impossible conditions.
2024-11-06 17:47:35 +01:00
Christoph M. Becker 30dd291628 Updates for libxml2 >= 2.13.0
libxml2 2.13.0 introduced some relevant changes regarding the treatment
of file paths on Windows[1].  Thus we un-xfail bug69753.phpt and its
companion, and we adjust dom004.phpt.  And we also disable the
workaround for erroneous file:/ URIs on Windows.

[1] <https://gitlab.gnome.org/GNOME/libxml2/-/commit/8ab1b122c47bfced2b59f52351507ebc1eb50218>

Closes GH-16536.
2024-10-22 00:17:12 +02:00
Niels Dossche bb46b4b799 Backport 4fe82131: Backport libxml2 2.13.2 fixes (#14816)
Backproted from https://github.com/php/php-src/pull/14789
2024-10-12 15:12:40 +02:00
Niels Dossche fa6a0f80f6 Backport 0a39890c: Fix libxml2 2.12 build due to API breaks
See https://github.com/php/php-src/actions/runs/7062192818/job/19225478601
2024-10-12 15:12:40 +02:00
Niels Dossche 6980eba863 Support templated content
The template element in HTML 5 is special in the sense that it does not
add its contents into the DOM tree, but instead keeps them in a separate
shadow DOM document fragment. Interacting with the DOM tree cannot touch
the elements in the document fragment.

Closes GH-14906.
2024-07-15 11:10:51 +02:00
Tim Düsterhus 29f98e7485 Replace @deprecated by #[\Deprecated] for internal functions / class constants (#14750)
Co-authored-by: Gina Peter Banyard <girgias@php.net>
Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
2024-07-10 16:47:31 +02:00
Niels Dossche ecf0bb0fd1 Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  [ci skip] NEWS
  Backport libxml2 2.13.2 fixes (#14816)
2024-07-04 15:37:35 +02:00
Niels Dossche 4fe821311c Backport libxml2 2.13.2 fixes (#14816)
Backproted from https://github.com/php/php-src/pull/14789
2024-07-04 15:29:50 +02:00
Niels Dossche d80be78efd Stop relying on the deprecated xmlLastError global 2024-07-03 10:34:46 -07:00
Niels Dossche 85705eda71 Fix compilation on libxml2 2.13 2024-07-03 10:34:46 -07:00
Niels Dossche fc09f4b2bc Implement Dom\TokenList (#13664)
Part of RFC: https://wiki.php.net/rfc/dom_additions_84

Closes GH-11688.
2024-07-02 21:34:23 +02:00
Niels Dossche 768900b180 Implement Dom $innerHTML property 2024-07-02 11:15:38 -07:00
Niels Dossche 88da914910 Implement CSS selectors 2024-06-29 13:00:26 -07:00
David Carlier 532a2604c2 Fix GH-14698: segfault on dom node after dereference.
close GH-14701
2024-06-28 20:52:48 +01:00
Gina Peter Banyard 25a5146180 Clean-up unused headers (#14365)
* ext/mbstring.c: clean-up headers and include intrinsics
2024-06-01 17:12:42 +01:00
Niels Dossche 90e0ce7f0d Throw early when a non-stream-context resource is passed to libxml_set_streams_context() (#14279) 2024-05-20 16:56:38 +02:00
Niels Dossche 230ab078d1 Avoid code duplication for error instance creation in ext/libxml (#14277) 2024-05-20 16:18:32 +02:00
Niels Dossche aa3e6eec50 Optimize and reduce memory usage of XML serialization (#14204)
The serialization process uses the system allocator and requires a copy
to request allocated memory once finished. This patch improves this by
using smart_str to build the resulting string, reducing the number of
copies and reducing total peak memory usage.
2024-05-12 01:57:29 +02:00
Niels Dossche dfde0d4cef Handle dumping node to file 2024-05-11 18:09:39 +02:00
Niels Dossche 0c490ade0d Handle dumping document to file 2024-05-11 18:09:39 +02:00
Niels Dossche 44485892df Factor out all common code for XML serialization and merge common paths 2024-05-11 18:09:39 +02:00
Niels Dossche fae25ca2df Move dom_attr_value() into ext/libxml 2024-05-05 10:14:40 +02:00
Niels Dossche cf7c592143 Simplify property check in php_libxml_node_free_resource() 2024-04-30 17:29:19 +02:00
Niels Dossche 974edc7939 Cleanup php_libxml_internal_error_handler_ex() 2024-04-30 17:29:19 +02:00
Niels Dossche e5e8b193e0 Remove bogus entity reference cleanup code 2024-04-30 17:29:19 +02:00
Niels Dossche 2fab1437f2 Cleanup php_libxml_streams_IO_open_wrapper() 2024-04-30 17:29:19 +02:00
Niels Dossche a54d63aefe Cleanup php_libxml_unregister_node() 2024-04-30 17:29:19 +02:00
Niels Dossche 30885f3b5f Implement request #71571: XSLT processor should provide option to change maxDepth (#13731)
There are two depth limiting parameters for XSLT templates.
1) maxTemplateDepth
   This corresponds to the recursion depth of a template. For very
   complicated templates this can be hit.
2) maxTemplateVars
   This is the total number of live variables. When using recursive
   templates with lots of parameters you can hit this limit.

This patch introduces two new properties to XSLTProcessor that
corresponds to the above variables.
2024-03-31 21:21:23 +02:00
Niels Dossche b955973818 Only register error handling when observable
Closes GH-13702.
2024-03-17 18:24:40 +01:00
Niels Dossche 14b6c981c3 [RFC] Add a way to opt-in ext/dom spec compliance (#13031)
RFC: https://wiki.php.net/rfc/opt_in_dom_spec_compliance
2024-03-09 16:56:00 +01:00
Niels Dossche a74da53fc4 Remove useless write to LIBXML(stream_context)
The value will always be overwritten.
2024-02-25 00:28:30 +01:00