Skip to content

Commit

Permalink
Fix coding standards.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 11, 2023
1 parent 36fbc01 commit 8490643
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,11 @@ private function parse_document( SimpleXMLElement $document ) {
return AcquirerStatusResMessage::parse( $document );
default:
throw new \Exception(
/* translators: %s: XML document element name */
sprintf( __( 'Unknown iDEAL message (%s)', 'pronamic_ideal' ), $name )
\sprintf(
/* translators: %s: XML document element name */
\esc_html__( 'Unknown iDEAL message (%s)', 'pronamic_ideal' ),
\esc_html( $name )
)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function start( Payment $payment ) {
throw new \Exception(
\sprintf(
'The iDEAL Advanced gateway cannot process `%s` payments, only iDEAL payments.',
$payment_method
\esc_html( $payment_method )

Check failure on line 169 in src/Gateway.php

View workflow job for this annotation

GitHub Actions / phpstan / phpstan

Parameter #1 $text of function esc_html expects string, string|null given.
)
);
}
Expand Down
24 changes: 21 additions & 3 deletions src/Integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,12 @@ public function get_settings_fields() {
'default' => 1825,
'tooltip' => __( 'Number of days the generated certificate will be valid for, e.g. 1825 days for the maximum duration of 5 years.', 'pronamic_ideal' ),
'input' => function ( $name ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing
if ( ! \array_key_exists( $name, $_POST ) ) {
return '';
}

// phpcs:ignore WordPress.Security.NonceVerification.Missing
return \filter_var( \sanitize_text_field( \wp_unslash( $_POST[ $name ] ) ), \FILTER_SANITIZE_NUMBER_INT );
},
];
Expand All @@ -187,12 +189,16 @@ public function get_settings_fields() {
'default' => wp_generate_password(),
'tooltip' => __( 'A random password which will be used for the generation of the secret key and certificate.', 'pronamic-ideal' ),
'input' => function ( $name ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing

if ( ! \array_key_exists( $name, $_POST ) ) {
return '';
}

// phpcs:ignore Detected usage of a non-sanitized input variable -- Password can contain whitespace, HTML tags and percent-encoded characters.
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Password can contain whitespace, HTML tags and percent-encoded characters.
return $_POST[ $name ];

// phpcs:enable WordPress.Security.NonceVerification.Missing
},
];

Expand All @@ -207,12 +213,16 @@ public function get_settings_fields() {
'classes' => [ 'code' ],
'tooltip' => __( 'The secret key is used for secure communication with the payment provider. If left empty, the secret key will be generated using the given secret key password.', 'pronamic-ideal' ),
'input' => function ( $name ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing

if ( ! \array_key_exists( $name, $_POST ) ) {
return '';
}

// phpcs:ignore Detected usage of a non-sanitized input variable -- Private key can contain whitespace, HTML tags and percent-encoded characters.
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Private key can contain whitespace, HTML tags and percent-encoded characters.
return $_POST[ $name ];

// phpcs:enable WordPress.Security.NonceVerification.Missing
},
];

Expand All @@ -227,12 +237,16 @@ public function get_settings_fields() {
'classes' => [ 'code' ],
'tooltip' => __( 'The certificate is used for secure communication with the payment provider. If left empty, the certificate will be generated using the secret key and given organization details.', 'pronamic-ideal' ),
'input' => function ( $name ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing

if ( ! \array_key_exists( $name, $_POST ) ) {
return '';
}

// phpcs:ignore Detected usage of a non-sanitized input variable -- Certificate can contain whitespace, HTML tags and percent-encoded characters.
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Certificate can contain whitespace, HTML tags and percent-encoded characters.
return $_POST[ $name ];

// phpcs:enable WordPress.Security.NonceVerification.Missing
},
];

Expand Down Expand Up @@ -557,6 +571,8 @@ public function maybe_download_secret_key() {
* @return void
*/
public function save_post( $post_id ) {
// phpcs:disable WordPress.Security.NonceVerification.Missing

// Files.
$files = [
'_pronamic_gateway_ideal_private_key_file' => '_pronamic_gateway_ideal_private_key',
Expand All @@ -573,6 +589,8 @@ public function save_post( $post_id ) {
}
}

// phpcs:enable WordPress.Security.NonceVerification.Missing

// Generate private key and certificate.
$private_key = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key', true );
$private_key_password = get_post_meta( $post_id, '_pronamic_gateway_ideal_private_key_password', true );
Expand Down

0 comments on commit 8490643

Please sign in to comment.