Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 7.4 deprecation octdec() #25

Merged
merged 6 commits into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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';