Skip to content

Commit de10a85

Browse files
GlombergAntonV1211
authored andcommitted
Fix. Contacts Encoder. Regex pattern for emails fixed.
1 parent 0e09daf commit de10a85

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

ContactsEncoder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ abstract class ContactsEncoder
3939
* Regular expressions parts.
4040
*/
4141
const ARIA_LABEL_PATTERN = '/aria-label.?=.?[\'"].+?[\'"]/';
42-
const EMAIL_PATTERN = '[_A-Za-z0-9-\.]+@[_A-Za-z0-9-\.]+\.[A-Za-z]{2,}';
42+
const EMAIL_PATTERN = '[_A-Za-z0-9-\.]+@[_A-Za-z0-9-\.]+\.[A-Za-z]{2,}\b';
43+
const EMAIL_PATTERN_DOMAIN_CATCHING = '[_A-Za-z0-9-\.]+@[_A-Za-z0-9-\.]+(\.[A-Za-z]{2,}\b)';
4344
const PHONE_NUMBER = '\+\d{8,12}';
4445
const PHONE_NUMBERS_PATTERNS = [
4546
'(tel:' . self::PHONE_NUMBER . ')', // tel:+XXXXXXXXXX
@@ -194,7 +195,7 @@ private function prepareRegularExpressions()
194195
{
195196
$this->aria_regex = self::ARIA_LABEL_PATTERN;
196197

197-
$this->global_email_pattern = '/(mailto\:\b' . self::EMAIL_PATTERN . '\b)|(\b' . self::EMAIL_PATTERN . '\b)/';
198+
$this->global_email_pattern = '/(mailto\:\b' . self::EMAIL_PATTERN . ')|(\b' . self::EMAIL_PATTERN_DOMAIN_CATCHING . ')/';
198199
$this->global_phones_pattern = '/' . implode('|', self::PHONE_NUMBERS_PATTERNS) . '/';
199200
$this->global_mailto_pattern = '/mailto\:(' . self::EMAIL_PATTERN . ')/';
200201
$this->plain_email_pattern = '/(\b' . self::EMAIL_PATTERN . '\b)/';

0 commit comments

Comments
 (0)