1
0
mirror of https://github.com/php/php-src.git synced 2026-04-28 10:43:30 +02:00

492 Commits

Author SHA1 Message Date
Ben Ramsey 1fbfabe18f license-update: ext/tidy source headers
RFC: https://wiki.php.net/rfc/php_license_update
2026-04-11 21:20:54 -05:00
Tim Düsterhus 04f06e8cf2 zend_portability: Remove EMPTY_SWITCH_DEFAULT_CASE() (#20063)
There are several issues with this macro:

- It is incorrectly named: It's not an empty default case. It's an unreachable
  default case.
- It is hiding control flow in its definition, which can be confusing for
  humans and tools (such as Coccinelle) alike, because it looks like it would
  be a statement that belongs to the "current" case rather than opening a new
  one.

Since this macro is exactly as long as explicitly spelling out its definition
(excluding the useless `break;`), it is not even making the code any more
succinct.
2026-04-06 14:46:15 +02:00
Gina Peter Banyard cd753007ce Audit INI functions and macros, and replace them with better alternatives (#21146)
Audit zend_ini_string(), INI_STR(), and related functions and macros, and all other INI_* macros.

The primary motivation is that these APIs should return a `const char*` because the `char*` is owned by a zend_string, and thus should never be released.

Moreover, the INI_STR() API doesn't follow our usual naming scheme as it returns a char* rather than a zend_string*.

In this PR new zend_ini_{bool|long|double|str|string}_literal() macros are introduced replacing the INI_{BOOL|INT|FLT|STR} macros which follow our more modern naming convention.
Moreover, the INI_BOOL() macro didn't produce correct values if the INI string is a word like "true" or "on".

The INI_ORIG_* APIs are removed because a Sourcegraph search shows 0 results, other than the one case used in ext/tidy that we fix using the typical API.

Add some additional checks for the value of an INI string to ensure it doesn't contain a nul byte when describing a path.
2026-03-30 14:48:12 +01:00
Peter Kokot f17c5ad83b Windows build: Add new function CHECK_HEADER() (#21191)
The current function `CHECK_HEADER_ADD_INCLUDE()` automatically defines
`HAVE_<HEADER_NAME_H>` preprocessor macros, which makes it difficult to
sync with other build systems. Specially, if some `HAVE_` macro is used
in the code and this function defines this macro but Autotools doesn't.

The new `CHECK_HEADER()` function behaves similar except it doesn't
define the `HAVE_<HEADER_NAME_H>` preprocessor macro.

This removes the following unused compile definitions:

HAVE_ARGON2_H
HAVE_AVIF_H
HAVE_BZLIB_H
HAVE_CAPSTONE_CAPSTONE_H
HAVE_CURL_EASY_H
HAVE_DB_H
HAVE_DECODE_H
HAVE_DEPOT_H
HAVE_EDITLINE_READLINE_H
HAVE_ENCHANT_H
HAVE_ENCODE_H
HAVE_FFI_H
HAVE_FIREBIRD_INTERFACE_H
HAVE_FT2BUILD_H
HAVE_GD_H
HAVE_GLIB_H
HAVE_GMP_H
HAVE_HTTPD_H
HAVE_IBASE_H
HAVE_IR_IR_H
HAVE_KECCAKHASH_H
HAVE_LBER_H
HAVE_LDAP_H
HAVE_LIBEXSLT_EXSLT_H
HAVE_LIBINTL_H
HAVE_LIBPQ_FE_H
HAVE_LIBTIDY_TIDY_H
HAVE_LIBXML_PARSER_H
HAVE_LIBXML_TREE_H
HAVE_LIBXML_XMLWRITER_H
HAVE_LIBXSLT_XSLT_H
HAVE_LMDB_H
HAVE_MBSTRING_H
HAVE_MYSQL_H
HAVE_ONIGURUMA_H
HAVE_OPENSSL_SSL_H
HAVE_PNG_H
HAVE_SNMP_H
HAVE_SODIUM_H
HAVE_SQLITE3_H
HAVE_SQLITE3EXT_H
HAVE_SYBFRONT_H
HAVE_TIDY_H
HAVE_TIDY_TIDY_H
HAVE_TIDYBUFFIO_H
HAVE_TIMELIB_CONFIG_H
HAVE_UNICODE_USPOOF_H
HAVE_UNICODE_UTF_H
HAVE_XPM_H
HAVE_ZIP_H
HAVE_ZIPCONF_H
HAVE_ZLIB_H

The following compile definitions are defined explicitly:

- HAVE_ICONV_H
- HAVE_MSCOREE_H
- HAVE_SQL_H
- HAVE_SQLEXT_H

Additionally, the `SETUP_OPENSSL()` function doesn't accept the 6th
argument anymore.
2026-03-03 20:06:40 +01:00
Ilija Tovilo 073dcf66bb Merge branch 'PHP-8.5'
* PHP-8.5:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:28 +01:00
Ilija Tovilo 07e29acbd4 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:21 +01:00
Ilija Tovilo 6f91209260 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:05:14 +01:00
Ilija Tovilo c6ad84fb9e Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2:
  Add RUN_RESOURCE_HEAVY_TESTS env var
2026-02-27 15:04:24 +01:00
Ilija Tovilo 3a57b4ced5 Add RUN_RESOURCE_HEAVY_TESTS env var
Disable resource-heavy tests by default (>1GB of memory usage), unless the
RUN_RESOURCE_HEAVY_TESTS env variable is set.

Fixes GH-20762
Closes GH-20935
2026-02-27 15:00:35 +01:00
Nurzhan Bazhirov b843e03c83 Zend: Remove unused parameter from zend_dval_to_lval_cap()
The `zend_string *s` parameter became unused after commit f754ffa8b2
(GH-20746) removed the `zend_oob_string_to_long_error()` calls.

This fixes an unused-parameter compiler warning and updates a stale
comment in zend_operators.c that incorrectly stated this function
can emit warnings.

Closes GH-21112
2026-02-04 15:25:42 +01:00
Arnaud Le Blanc 65b4073922 Include the actual stub name in generated arginfo headers (#20993) 2026-01-21 20:57:00 +01:00
Bob Weinand 434b14e4a3 Merge branch 'PHP-8.5' 2025-12-29 21:30:42 +01:00
Bob Weinand f754ffa8b2 Fixed bug GH-20745 ("Casting out of range floats to int" applies to strings) (#20746)
This reverts the warning for float-strings, to whose it never should have been applied in the first place.
2025-12-29 21:29:08 +01:00
Niels Dossche 4461e29b65 Merge branch 'PHP-8.5'
* PHP-8.5:
  tidy: Harden against tidyNodeGetText() failure
2025-11-05 20:22:54 +01:00
Niels Dossche edcbd4a656 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  tidy: Harden against tidyNodeGetText() failure
2025-11-05 20:22:47 +01:00
Niels Dossche ad248cfe58 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  tidy: Harden against tidyNodeGetText() failure
2025-11-05 20:22:39 +01:00
Niels Dossche 0584e59734 tidy: Harden against tidyNodeGetText() failure
Either the buffer size or the return value needs to be checked.
From a quick look into the tidy source code, this can't fail right now
for our use case in practice, but it might in the future.

Closes GH-20389.
2025-11-05 20:21:32 +01:00
Niels Dossche 331e6ae548 tidy: Avoid some work when creating attributes (#20390)
We know these can't be numeric strings, so directly use the hash table
APIs. Also use ZVAL_STRING_FAST because many attributes are 0/1 chars
long.
2025-11-05 20:13:32 +01:00
Niels Dossche 5b5fe437f5 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-20374: PHP with tidy and custom-tags
  pgsql: Fix memory leak when object init fails (#20387)
2025-11-04 20:21:17 +01:00
Niels Dossche b8e9f7c44c Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-20374: PHP with tidy and custom-tags
  pgsql: Fix memory leak when object init fails (#20387)
2025-11-04 20:21:09 +01:00
Niels Dossche 07aab0c356 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-20374: PHP with tidy and custom-tags
  pgsql: Fix memory leak when object init fails (#20387)
2025-11-04 20:20:26 +01:00
Niels Dossche fcc159b4f6 Fix GH-20374: PHP with tidy and custom-tags
Both enums and integers map to TidyInteger, however, in the TidyInteger
case we always used zval_get_long(). So for a non-numeric string, this
would get turned into 0. 0 is the first enum value in that case, so the
wrong enum value could be selected.

To solve this, add special handling for strings and (stringable) objects
such that we can explicitly check for numeric strings, and if they're
not, handle them as normal strings instead of as 0.

Closes GH-20387.
2025-11-04 20:00:22 +01:00
Niels Dossche 7455f6a5b0 Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix macro check that I forgot to commit
  Fix UAF in tidy when tidySetErrorBuffer() fails
2025-10-24 21:20:58 +02:00
Niels Dossche 67926db749 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix macro check that I forgot to commit
  Fix UAF in tidy when tidySetErrorBuffer() fails
2025-10-24 21:20:52 +02:00
Niels Dossche 9e4fbb5ca8 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix UAF in tidy when tidySetErrorBuffer() fails
2025-10-24 21:20:43 +02:00
Niels Dossche 58df9fcf98 Fix UAF in tidy when tidySetErrorBuffer() fails
We should not free `intern` as its stored in the object store as well,
so the object store will already free it, leading to a UAF when the
object store tries to read the object's fields.

Closes GH-20276.
2025-10-24 21:19:47 +02:00
Peter Kokot 01e339d8b8 ext/tidy: Enable tidyOptGetCategory on Windows (#20226)
The tidy library on Windows has been updated to tidy-html5 5.6.0 which
provides tidyOptGetCategory() function and has the TidyInternalCategory
enumeration.

https://github.com/winlibs/libtidy
2025-10-20 14:52:46 +02:00
Peter Kokot 552c588d4f Merge branch 'PHP-8.5'
* PHP-8.5:
  Fix GH-19021: improve tidyOptGetCategory detection
2025-10-19 20:55:38 +02:00
Peter Kokot c2523ed581 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  Fix GH-19021: improve tidyOptGetCategory detection
2025-10-19 20:54:55 +02:00
Peter Kokot b5c4435567 Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  Fix GH-19021: improve tidyOptGetCategory detection
2025-10-19 20:53:37 +02:00
David Carlier ebbb1b4295 Fix GH-19021: improve tidyOptGetCategory detection
We now check both this symbol and TidyInternalCategory presence.

Co-authored-by: Peter Kokot <peterkokot@gmail.com>
2025-10-19 20:52:19 +02:00
Niels Dossche 57ce245e1e Reduce code bloat in arginfo by using specialised string releases (#20016)
* Reduce code bloat in arginfo by using specialised string releases

Comparing this patch to master (c7da728574),
with a plain configure command without any options:

```
   text	   data	    bss	    dec	    hex	filename
20683738	1592400	 137712	22413850	156021a	sapi/cli/php
20688522	1592400	 137712	22418634	15614ca	sapi/cli/php_old
```

We see a minor reduction of 0.023% in code size.

* Also use true for the other initialization line

* Also use specialized code for consts
2025-10-02 22:00:20 +02:00
David Carlier 1299376b8f Merge branch 'PHP-8.4' 2025-08-16 19:28:11 +01:00
David Carlier 0fc3a2e624 Merge branch 'PHP-8.3' into PHP-8.4 2025-08-16 19:28:00 +01:00
Arjen de Korte a97717d23e Fix GH-19021: deprecation for tidyOptIsReadOnly
The tidyOptGetCategory function (added in libtidy 5.4.0) if only useable if TidyInternalCategory (added in libtidy 5.6.0) is also present, so check for the latter instead.

close GH-19053
2025-08-16 19:24:47 +01:00
Gina Peter Banyard 1e0c8baf05 tree: drop non canonical casts and ZPP tests 2025-08-06 13:20:28 +01:00
Gina Peter Banyard 419f6750c0 ext/tidy: refactor php_tidy_file_to_mem()
Pass zend_string* along
2025-07-18 13:21:56 +01:00
Gina Peter Banyard 4433986e40 ext/tidy: Refactor php_tidy_parse_string() 2025-07-18 13:21:56 +01:00
Gina Peter Banyard 0a130caf58 ext/tidy: refactor php_tidy_set_tidy_opt()
Bring closer to unique call site and return value of it
2025-07-18 13:21:56 +01:00
Gina Peter Banyard 01dbee83e1 ext/tidy: tidyOptGetType returns an enum that is fully checked 2025-07-18 13:21:56 +01:00
DanielEScherzer ddd33fd7e4 Generated arginfo headers: combine preprocessor conditional blocks (2) (#18667)
When global constants' or class constants' availability is based on some
preprocessor condition, the generated arginfo header files wrap the
declarations in the preprocessor `#if` conditional blocks, one per declaration,
even if they are in the same conditional block based on comments in the stub
file. Instead of having multiple conditional blocks one after the other with
the same condition, combine them into a single conditional block.
2025-06-22 14:35:28 -07:00
David CARLIER 01c3001eb7 ext/tidy: zend_parse_parameters_none -> ZEND_PARSE_PARAMETERS_NONE macro (#18913) 2025-06-22 19:47:36 +01:00
Gina Peter Banyard 19b1173577 ext/tidy: Add some const qualifiers 2025-06-05 19:46:04 +01:00
Gina Peter Banyard d97a90acb8 ext/tidy: Use zend_result type instead of int type 2025-06-05 19:46:04 +01:00
Gina Peter Banyard feff5381b4 ext/tidy: Reduce scope of variable and rename to prevent variable shadowing 2025-06-05 19:46:04 +01:00
Gina Peter Banyard 25057811a5 ext/tidy: Use RETURN_BOOL() where possible 2025-06-05 19:46:04 +01:00
Gina Peter Banyard bf3d7d1f9a ext/tidy: Use RETURN_STR() instead of RETVAL_STR() + return; 2025-06-05 19:46:04 +01:00
Gina Peter Banyard 4fd91c6fa4 ext/tidy: Use RETURN_THROWS() macro 2025-06-05 19:46:04 +01:00
Gina Peter Banyard b7db5c8129 ext/tidy: Remove TIDY_SET_CONTEXT macro 2025-06-05 19:46:04 +01:00
Gina Peter Banyard d40e3200a7 ext/tidy: Use uint32_t and bool types instead of unsigned int type
On certain platform an unsigned int is 64bits, which is not needed.
2025-06-05 19:46:04 +01:00