Sanitize the key as a text field if we don't know what it is

This commit is contained in:
Thomas Roberts 2024-03-07 14:53:33 +00:00
parent 109fbe766c
commit 9f5071051c
No known key found for this signature in database
GPG Key ID: 0262BEBCBE336365
1 changed files with 2 additions and 0 deletions

View File

@ -123,6 +123,8 @@ abstract class AbstractAddressSchema extends AbstractSchema {
array_keys( $address ),
function( $carry, $key ) use ( $address, $validation_util, $field_schema ) {
if ( ! isset( $field_schema[ $key ] ) ) {
// Sanitize text field since we have no info about what it *should* be. Sanitizing it is safer than leaving it alone.
$carry[ $key ] = sanitize_text_field( $address[ $key ] );
return $carry;
}
switch ( $key ) {