Skip to content

Commit

Permalink
Merge pull request #1958 from Codeinwp/fix/form-base64-checker
Browse files Browse the repository at this point in the history
Remove obsolete base64 checking in Form File validation
  • Loading branch information
HardeepAsrani authored Nov 9, 2023
2 parents c663815 + 4a2e954 commit 2f2e904
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions inc/integrations/class-form-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public static function is_file_field( $field ) {
* @since 2.2.3
*/
public static function is_file_field_valid( $field ) {
return isset( $field['metadata']['name'] ) && isset( $field['metadata']['size'] ) && isset( $field['metadata']['data'] ) && is_string( $field['metadata']['name'] ) && is_numeric( $field['metadata']['size'] ) && is_string( $field['metadata']['data'] ) && self::is_base64_string( $field['metadata']['data'] );
return isset( $field['metadata']['name'] ) && isset( $field['metadata']['size'] ) && isset( $field['metadata']['data'] ) && is_string( $field['metadata']['name'] ) && is_numeric( $field['metadata']['size'] ) && is_string( $field['metadata']['data'] );
}

/**
Expand Down Expand Up @@ -140,17 +140,4 @@ public static function generate_file_name( $original_name ) {

return $hash_code . '_' . $original_name;
}

/**
* Check if a string is a valid base64 string.
*
* @param string $data String to check.
* @return boolean
* @since 2.2.3
*/
public static function is_base64_string( $data ) {
// Separate out the headers from the data.
$parts = explode( ';base64,', $data );
return preg_match( '%^[a-zA-Z0-9/+]*={0,2}$%', $parts[1] );
}
}

0 comments on commit 2f2e904

Please sign in to comment.