diff --git a/includes/class-classifier.php b/includes/class-classifier.php index 4eaaf13..63c6860 100644 --- a/includes/class-classifier.php +++ b/includes/class-classifier.php @@ -226,6 +226,7 @@ final class Classifier * shape). Deeper nesting is intentionally NOT supported. * * @param array $fields CF7 posted_data + * @return bool True if any value contains a syntactically valid email */ public static function has_valid_email_anywhere(array $fields): bool { @@ -252,7 +253,10 @@ final class Classifier * the value-based heuristic in FieldDetector::find_name(). Returns false if no name * field is present (i.e. forms without a name field are immune to this rule). * + * Cyrillic look-alikes (e.g. 'ОВ') are rejected because the regex is byte-range. + * * @param array $fields CF7 posted_data + * @return bool True if a name field exists and is 1-3 ASCII alphanumeric chars */ public static function has_short_latin_name(array $fields): bool { diff --git a/tests/ClassifierDropTest.php b/tests/ClassifierDropTest.php index 6b91278..ff77f92 100644 --- a/tests/ClassifierDropTest.php +++ b/tests/ClassifierDropTest.php @@ -81,4 +81,25 @@ final class ClassifierDropTest extends Cf7stgTestCase $fields = ['text-211' => 'XY', 'text-212' => '+79991234567']; self::assertTrue(Classifier::has_short_latin_name($fields)); } + + public function test_has_short_latin_name_true_for_single_letter_boundary(): void + { + // Lower boundary of {1,3}: 1 char accepted + $fields = ['your-name' => 'A']; + self::assertTrue(Classifier::has_short_latin_name($fields)); + } + + public function test_has_short_latin_name_false_for_four_letters_boundary(): void + { + // Upper boundary of {1,3}: 4 chars rejected + $fields = ['your-name' => 'ABCD']; + self::assertFalse(Classifier::has_short_latin_name($fields)); + } + + public function test_has_short_latin_name_false_for_array_value_with_space_join(): void + { + // pick_field joins array values with a space → "OB MU" is 5 chars → no false positive. + $fields = ['your-name' => ['OB', 'MU']]; + self::assertFalse(Classifier::has_short_latin_name($fields)); + } }