From 6817774db20780e21c092a797ef25516d9322d6c Mon Sep 17 00:00:00 2001 From: Florian Brinkmann Date: Sat, 6 Jul 2024 18:27:57 +0200 Subject: [PATCH 1/2] feat: add `scrape` regex test for useragent string --- src/Rules/RegexpSpam.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Rules/RegexpSpam.php b/src/Rules/RegexpSpam.php index 615c9bc0..e2780f75 100644 --- a/src/Rules/RegexpSpam.php +++ b/src/Rules/RegexpSpam.php @@ -111,6 +111,9 @@ public static function verify( array $item ): int { [ 'rawurl' => '^http[s]?:\/\/(accounts\.)?binance\.com\/[a-zA-Z-]+\/register(-person)?\?ref=[\w]+', ], + [ + 'useragent' => 'scrape', + ] ]; $quoted_author = preg_quote( $subject['author'], '/' ); @@ -154,6 +157,10 @@ public static function verify( array $item ): int { continue; } + if ( ! isset( $subject[ $field ] ) ) { + continue; + } + $subject[ $field ] = ( function_exists( 'iconv' ) ? iconv( 'utf-8', 'utf-8//TRANSLIT', $subject[ $field ] ) : $subject[ $field ] ); if ( empty( $subject[ $field ] ) ) { From 411e3f3f111e629936511de77aaeaa985ea78594 Mon Sep 17 00:00:00 2001 From: Florian Brinkmann Date: Sat, 6 Jul 2024 18:29:21 +0200 Subject: [PATCH 2/2] fix: PHPCS issue --- src/Rules/RegexpSpam.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Rules/RegexpSpam.php b/src/Rules/RegexpSpam.php index e2780f75..24564fe3 100644 --- a/src/Rules/RegexpSpam.php +++ b/src/Rules/RegexpSpam.php @@ -113,7 +113,7 @@ public static function verify( array $item ): int { ], [ 'useragent' => 'scrape', - ] + ], ]; $quoted_author = preg_quote( $subject['author'], '/' );