Make sure payment gateway title is a string before sanitizing (#33434)

Make sure payment gateway title is a string before sanitizing.

* Add changelog
* Drop type-hint in `validate_safe_text_field()`
* Update plugins/woocommerce/includes/abstracts/abstract-wc-settings-api.php

Co-authored-by: Barry Hughes <3594411+barryhughes@users.noreply.github.com>
This commit is contained in:
Jorge A. Torres 2022-06-15 14:49:11 -03:00 committed by GitHub
parent 55eebebeba
commit f0b9adc7ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Make sure payment gateway title is a string before sanitizing

View File

@ -305,7 +305,7 @@ abstract class WC_Payment_Gateway extends WC_Settings_API {
* @return string
*/
public function get_title() {
$title = wc_get_container()->get( HtmlSanitizer::class )->sanitize( $this->title, HtmlSanitizer::LOW_HTML_BALANCED_TAGS_NO_LINKS );
$title = wc_get_container()->get( HtmlSanitizer::class )->sanitize( (string) $this->title, HtmlSanitizer::LOW_HTML_BALANCED_TAGS_NO_LINKS );
return apply_filters( 'woocommerce_gateway_title', $title, $this->id );
}

View File

@ -868,8 +868,8 @@ abstract class WC_Settings_API {
*
* @return string
*/
public function validate_safe_text_field( string $key, string $value ): string {
return wc_get_container()->get( HtmlSanitizer::class )->sanitize( $value, HtmlSanitizer::LOW_HTML_BALANCED_TAGS_NO_LINKS );
public function validate_safe_text_field( string $key, ?string $value ): string {
return wc_get_container()->get( HtmlSanitizer::class )->sanitize( (string) $value, HtmlSanitizer::LOW_HTML_BALANCED_TAGS_NO_LINKS );
}
/**