From 0ca21ddf860e7ff796535e78592a0d1c4c5bbe4d Mon Sep 17 00:00:00 2001 From: David Riccitelli Date: Sun, 3 Sep 2023 16:57:55 +0300 Subject: [PATCH] be sure to trim URL values --- src/includes/class-wordlift-sanitizer.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/includes/class-wordlift-sanitizer.php b/src/includes/class-wordlift-sanitizer.php index 6954274eb5..b068b34f65 100644 --- a/src/includes/class-wordlift-sanitizer.php +++ b/src/includes/class-wordlift-sanitizer.php @@ -17,8 +17,13 @@ public static function sanitize_url( $value ) { // // see also http://stackoverflow.com/questions/2137080/php-filter-var-filter-validate-url - if ( $value !== null && '' !== $value ) { - return $value; + if ( ! is_string( $value ) ) { + return null; + } + + $trimmed_value = trim( $value ); + if ( '' !== $trimmed_value ) { + return $trimmed_value; } return null;