From 58709cff791d28ec4cbac799e63d4b96964455db Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 28 Nov 2024 23:09:12 -0600 Subject: [PATCH 1/2] RSA: PHP 8.4 deprecated xml_set_object() --- phpseclib/Crypt/RSA.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phpseclib/Crypt/RSA.php b/phpseclib/Crypt/RSA.php index 15aab4ab..dfc82bb6 100644 --- a/phpseclib/Crypt/RSA.php +++ b/phpseclib/Crypt/RSA.php @@ -1478,9 +1478,14 @@ class Crypt_RSA $this->components = array(); $xml = xml_parser_create('UTF-8'); - xml_set_object($xml, $this); - xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler'); - xml_set_character_data_handler($xml, '_data_handler'); + if (version_compare(PHP_VERSION, '8.4.0', '>=')) { + xml_set_element_handler($xml, array($this, '_start_element_handler'), array($this, '_stop_element_handler')); + xml_set_character_data_handler($xml, array($this, '_data_handler')); + } else { + xml_set_object($xml, $this); + xml_set_element_handler($xml, '_start_element_handler', '_stop_element_handler'); + xml_set_character_data_handler($xml, '_data_handler'); + } // add to account for "dangling" tags like ... that are sometimes added if (!xml_parse($xml, '' . $key . '')) { xml_parser_free($xml); From 05085f4df0fbc143e775bc4e921d031c2208b493 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Thu, 28 Nov 2024 23:24:31 -0600 Subject: [PATCH 2/2] BigInteger: fix for PHP 8.4.0 - 8.4.1 regression See https://github.com/php/php-src/issues/16870 --- phpseclib/Math/BigInteger.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpseclib/Math/BigInteger.php b/phpseclib/Math/BigInteger.php index a415f192..066788ad 100644 --- a/phpseclib/Math/BigInteger.php +++ b/phpseclib/Math/BigInteger.php @@ -246,7 +246,8 @@ class Math_BigInteger { if (!defined('MATH_BIGINTEGER_MODE')) { switch (true) { - case extension_loaded('gmp'): + // PHP 8.4.0 and 8.4.1 don't work with GMP per https://github.com/php/php-src/issues/16870 + case extension_loaded('gmp') && !(version_compare(PHP_VERSION, '8.4.0', '>=') && version_compare(PHP_VERSION, '8.4.1', '<=')): define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_GMP); break; case extension_loaded('bcmath'):