Skip to content

Commit

Permalink
Merge pull request #25 from alexpott/php74-deprecation
Browse files Browse the repository at this point in the history
Fix PHP 7.4 deprecation octdec()
  • Loading branch information
mrook authored Oct 21, 2019
2 parents f4e7378 + 359f898 commit 8361bf5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ install:
# - pear upgrade --force --alldeps pear/pear
- pear install -f package.xml
script:
- pear version
- pear run-tests -qr tests/
- for i in `find tests/ -name '*.out'`; do echo "$i"; cat "$i"; done
11 changes: 10 additions & 1 deletion Archive/Tar.php
Original file line number Diff line number Diff line change
Expand Up @@ -1692,7 +1692,16 @@ public function _readHeader($v_binary_data, &$v_header)
}

// ----- Extract the checksum
$v_header['checksum'] = OctDec(trim($v_data['checksum']));
$v_data_checksum = trim($v_data['checksum']);
if (!preg_match('/^[0-7]*$/', $v_data_checksum)) {
$this->_error(
'Invalid checksum for file "' . $v_data['filename']
. '" : ' . $v_data_checksum . ' extracted'
);
return false;
}

$v_header['checksum'] = OctDec($v_data_checksum);
if ($v_header['checksum'] != $v_checksum) {
$v_header['filename'] = '';

Expand Down
2 changes: 1 addition & 1 deletion tests/invalidchecksum.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $phpunit->assertErrors(array(
array('package' => 'PEAR_Error', 'message' => "Invalid checksum for file \"4&2Vib~Au.=ZqMTw~=}UoF/~5Gs;JTXF*<FyG\"\n" .
'1Hvu#nol Y 21/{G9i|D=$GTI KREuA\wI<wM@dYOKzS{6&]QE8ud|EPb:f?-Gt' . "\n" .
'I#)E9)@;_.0y9`P,&jY! :\.J8uG/a8,.vT[$Fe;>}hm\"#xO7:46y_tg6c-[A&S]z0fke?(B6?$:W$X{E%PO>~UWl8(' . "\n" .
'.%RWPjN55)cd&?oJPgFFZj#+U<qrF:9yIRe\" : 39049 calculated, 5 expected')), 'after 1');
'.%RWPjN55)cd&?oJPgFFZj#+U<qrF:9yIRe\" : UPJX05Zz extracted')), 'after 1');
echo 'tests done';
?>
--CLEAN--
Expand Down
2 changes: 1 addition & 1 deletion tests/phpt_test.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PEAR_PHPTest
{
var $_diffonly;
var $_errors;
function PEAR_PHPTest($diffonly = false, $noStackCatch = false)
function __construct($diffonly = false, $noStackCatch = false)
{
$this->_diffonly = $diffonly;
$this->_errors = array();
Expand Down
1 change: 1 addition & 0 deletions tests/setup.php.inc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
error_reporting(E_ALL);
require_once dirname(__FILE__) . '/phpt_test.php.inc';
$phpunit = new PEAR_PHPTest(true);
require_once dirname(dirname(__FILE__)) . '/Archive/Tar.php';

0 comments on commit 8361bf5

Please sign in to comment.