From 086802321689134c309d3ca303eac7681e19ab07 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Fri, 10 Dec 2021 07:39:19 -0600 Subject: [PATCH 1/2] Travis: add PHP 8.1.0 --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ef659a19..6521abde 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,8 @@ matrix: dist: xenial - php: 8.0 dist: bionic + - php: 8.1.0 + dist: bionic before_install: true From 624f328c88560e2ee6aa5f1ef8264cd318579c24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4fer?= Date: Tue, 14 Dec 2021 13:18:33 +0100 Subject: [PATCH 2/2] Remove define() from SSH2 and use class constants instead --- phpseclib/Net/SSH2.php | 60 ++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 6d0c4762..6863ebb2 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -61,23 +61,6 @@ use phpseclib\Crypt\Twofish; use phpseclib\Math\BigInteger; // Used to do Diffie-Hellman key exchange and DSA/RSA signature verification. use phpseclib\System\SSH\Agent; -/**#@+ - * @access private - */ -/** - * No compression - */ -define('NET_SSH2_COMPRESSION_NONE', 1); -/** - * zlib compression - */ -define('NET_SSH2_COMPRESSION_ZLIB', 2); -/** - * zlib@openssh.com - */ -define('NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH', 3); -/**#@-*/ - /** * Pure-PHP implementation of SSHv2. * @@ -87,6 +70,25 @@ define('NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH', 3); */ class SSH2 { + /**#@+ + * Compression Types + * + * @access private + */ + /** + * No compression + */ + const NET_SSH2_COMPRESSION_NONE = 1; + /** + * zlib compression + */ + const NET_SSH2_COMPRESSION_ZLIB = 2; + /** + * zlib@openssh.com + */ + const NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH = 3; + /**#@-*/ + /**#@+ * Execution Bitmap Masks * @@ -1002,7 +1004,7 @@ class SSH2 * @var int * @access private */ - var $compress = NET_SSH2_COMPRESSION_NONE; + var $compress = self::NET_SSH2_COMPRESSION_NONE; /** * Decompression method @@ -1010,7 +1012,7 @@ class SSH2 * @var resource|object * @access private */ - var $decompress = NET_SSH2_COMPRESSION_NONE; + var $decompress = self::NET_SSH2_COMPRESSION_NONE; /** * Compression context @@ -1644,9 +1646,9 @@ class SSH2 } $compression_map = array( - 'none' => NET_SSH2_COMPRESSION_NONE, - 'zlib' => NET_SSH2_COMPRESSION_ZLIB, - 'zlib@openssh.com' => NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH + 'none' => self::NET_SSH2_COMPRESSION_NONE, + 'zlib' => self::NET_SSH2_COMPRESSION_ZLIB, + 'zlib@openssh.com' => self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH ); $compression_algorithm_out = $this->_array_intersect_first($c2s_compression_algorithms, $this->compression_algorithms_client_to_server); @@ -3589,11 +3591,11 @@ class SSH2 } switch ($this->decompress) { - case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: + case self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: if (!$this->isAuthenticated()) { break; } - case NET_SSH2_COMPRESSION_ZLIB: + case self::NET_SSH2_COMPRESSION_ZLIB: if ($this->regenerate_decompression_context) { $this->regenerate_decompression_context = false; @@ -4181,11 +4183,11 @@ class SSH2 } switch ($this->compress) { - case NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: + case self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH: if (!$this->isAuthenticated()) { break; } - case NET_SSH2_COMPRESSION_ZLIB: + case self::NET_SSH2_COMPRESSION_ZLIB: if (!$this->regenerate_compression_context) { $header = ''; } else { @@ -4943,9 +4945,9 @@ class SSH2 $this->_connect(); $compression_map = array( - NET_SSH2_COMPRESSION_NONE => 'none', - NET_SSH2_COMPRESSION_ZLIB => 'zlib', - NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH => 'zlib@openssh.com' + self::NET_SSH2_COMPRESSION_NONE => 'none', + self::NET_SSH2_COMPRESSION_ZLIB => 'zlib', + self::NET_SSH2_COMPRESSION_ZLIB_AT_OPENSSH => 'zlib@openssh.com' ); return array(