feat(classifier): has_short_latin_name() helper for drop-logic
This commit is contained in:
@@ -243,4 +243,23 @@ final class Classifier
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the form's name field contains 1-3 ASCII alphanumeric characters
|
||||
* (typical bot pattern: "OB", "MU", "A1B"). Used by drop hard-rule.
|
||||
*
|
||||
* Looks first at canonical CF7 keys (your-name, name, имя, fio), then falls back to
|
||||
* 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).
|
||||
*
|
||||
* @param array<string,string|string[]> $fields CF7 posted_data
|
||||
*/
|
||||
public static function has_short_latin_name(array $fields): bool
|
||||
{
|
||||
$name = self::pick_field($fields, ['your-name', 'name', 'имя', 'fio']);
|
||||
if ($name === '') $name = FieldDetector::find_name($fields);
|
||||
$name = trim($name);
|
||||
if ($name === '') return false;
|
||||
return (bool)preg_match('/^[A-Za-z0-9]{1,3}$/', $name);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user