Skip to content

Commit 670c27f

Browse files
Extract checksums regardless of length and account for sha1 encryption. (#45)
1 parent 6047ed6 commit 670c27f

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

change_log.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
= 1.8 =
2+
- Fixed a bug where the verify checksums command fails even when it should succeed.
3+
14
= 1.7 =
25
- Fixed a bug that sometimes causes the form ID to be stored as a string.
36

cli.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Plugin Name: Gravity Forms CLI
44
Plugin URI: https://gravityforms.com
55
Description: Manage Gravity Forms with the WP CLI.
6-
Version: 1.7
6+
Version: 1.8
77
Author: Rocketgenius
88
Author URI: https://gravityforms.com
99
License: GPL-2.0+
@@ -30,7 +30,7 @@
3030
defined( 'ABSPATH' ) || defined( 'WP_CLI' ) || die();
3131

3232
// Defines the current version of the CLI add-on
33-
define( 'GF_CLI_VERSION', '1.7' );
33+
define( 'GF_CLI_VERSION', '1.8' );
3434

3535
define( 'GF_CLI_MIN_GF_VERSION', '1.9.17.8' );
3636

includes/class-gf-cli-tool.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,20 @@ public function verify_checksums( $args, $assoc_args ) {
8282

8383
$has_errors = false;
8484
foreach ( $checksums as $checksum_string ) {
85-
$checksum = substr( $checksum_string, 0, 32 );
86-
$file = str_replace( $checksum . ' ', '', $checksum_string );
85+
list( $checksum, $file ) = explode( ' ', $checksum_string );
8786
$path = GFCommon::get_base_path() . DIRECTORY_SEPARATOR . $file;
8887
if ( ! file_exists( $path ) ) {
8988
WP_CLI::warning( "File doesn't exist: {$file}" );
9089
$has_errors = true;
9190
continue;
9291
}
93-
$md5_file = md5_file( $path );
94-
if ( $md5_file !== $checksum ) {
92+
$hashed_file = '';
93+
if ( strlen( $checksum ) === 32 ) {
94+
$hashed_file = md5_file( $path );
95+
} elseif ( strlen( $checksum ) === 40 ) {
96+
$hashed_file = sha1_file( $path );
97+
}
98+
if ( $hashed_file !== $checksum ) {
9599
WP_CLI::warning( "File doesn't verify against checksum: {$file}" );
96100
$has_errors = true;
97101
}

0 commit comments

Comments
 (0)