Skip to content

Commit

Permalink
Fix bad Valid Phone Number Pattern regex
Browse files Browse the repository at this point in the history
Closes #76
  • Loading branch information
giggsey committed Aug 7, 2015
1 parent 9ad9a07 commit 7116dcb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Tests/libphonenumber/Tests/Issues/Issue76Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace libphonenumber\Tests\Issues;

use libphonenumber\PhoneNumberUtil;

class Issue76Test extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \libphonenumber\NumberParseException
* @expectedExceptionCode 1
* @expectedExceptionMessage The string supplied did not seem to be a phone number.
*/
public function testIssue76()
{
$number = 'Abc811@hotmail.com';
$region = 'DE';
$util = PhoneNumberUtil::getInstance();
$util->parse($number, $region);
}
}
2 changes: 1 addition & 1 deletion src/libphonenumber/PhoneNumberUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private function __construct(MetadataSourceInterface $metadataSource, $countryCa

self::$MIN_LENGTH_PHONE_NUMBER_PATTERN = "[" . self::DIGITS . "]{" . self::MIN_LENGTH_FOR_NSN . "}";
self::$VALID_PHONE_NUMBER = "[" . self::PLUS_CHARS . "]*(?:[" . self::VALID_PUNCTUATION . self::STAR_SIGN . "]*[" . self::DIGITS . "]){3,}[" . self::VALID_PUNCTUATION . self::STAR_SIGN . self::VALID_ALPHA . self::DIGITS . "]*";
self::$VALID_PHONE_NUMBER_PATTERN = "%^" . self::$MIN_LENGTH_PHONE_NUMBER_PATTERN . "$|^" . self::$VALID_PHONE_NUMBER . "(?:" . self::$EXTN_PATTERNS_FOR_PARSING . ")?%" . self::REGEX_FLAGS;
self::$VALID_PHONE_NUMBER_PATTERN = "%^" . self::$MIN_LENGTH_PHONE_NUMBER_PATTERN . "$|^" . self::$VALID_PHONE_NUMBER . "(?:" . self::$EXTN_PATTERNS_FOR_PARSING . ")?$%" . self::REGEX_FLAGS;

self::$UNWANTED_END_CHAR_PATTERN = "[^" . self::DIGITS . self::VALID_ALPHA . "#]+$";

Expand Down

0 comments on commit 7116dcb

Please sign in to comment.