@@ 952-974 (lines=23) @@ | ||
949 | } |
|
950 | } |
|
951 | switch ($patternselect) { |
|
952 | case 'pcre8': |
|
953 | /* |
|
954 | * Conforms to RFC5322: Uses *correct* regex on which FILTER_VALIDATE_EMAIL is |
|
955 | * based; So why not use FILTER_VALIDATE_EMAIL? Because it was broken to |
|
956 | * not allow a@b type valid addresses :( |
|
957 | * |
|
958 | * @link http://squiloople.com/2009/12/20/email-address-validation/ |
|
959 | * @copyright 2009-2010 Michael Rushton |
|
960 | * Feel free to use and redistribute this code. But please keep this copyright notice. |
|
961 | */ |
|
962 | return (bool) preg_match( |
|
963 | '/^(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){255,})(?!(?>(?1)"?(?>\\\[ -~]|[^"])"?(?1)){65,}@)'. |
|
964 | '((?>(?>(?>((?>(?>(?>\x0D\x0A)?[\t ])+|(?>[\t ]*\x0D\x0A)?[\t ]+)?)(\((?>(?2)'. |
|
965 | '(?>[\x01-\x08\x0B\x0C\x0E-\'*-\[\]-\x7F]|\\\[\x00-\x7F]|(?3)))*(?2)\)))+(?2))|(?2))?)'. |
|
966 | '([!#-\'*+\/-9=?^-~-]+|"(?>(?2)(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\x7F]))*'. |
|
967 | '(?2)")(?>(?1)\.(?1)(?4))*(?1)@(?!(?1)[a-z0-9-]{64,})(?1)(?>([a-z0-9](?>[a-z0-9-]*[a-z0-9])?)'. |
|
968 | '(?>(?1)\.(?!(?1)[a-z0-9-]{64,})(?1)(?5)){0,126}|\[(?:(?>IPv6:(?>([a-f0-9]{1,4})(?>:(?6)){7}'. |
|
969 | '|(?!(?:.*[a-f0-9][:\]]){8,})((?6)(?>:(?6)){0,6})?::(?7)?))|(?>(?>IPv6:(?>(?6)(?>:(?6)){5}:'. |
|
970 | '|(?!(?:.*[a-f0-9]:){6,})(?8)?::(?>((?6)(?>:(?6)){0,4}):)?))?(25[0-5]|2[0-4][0-9]|1[0-9]{2}'. |
|
971 | '|[1-9]?[0-9])(?>\.(?9)){3}))\])(?1)$/isD', |
|
972 | $address |
|
973 | ); |
|
974 | break; |
|
975 | case 'pcre': |
|
976 | //An older regex that doesn't need a recent PCRE |
|
977 | return (bool) preg_match( |
|
@@ 975-990 (lines=16) @@ | ||
972 | $address |
|
973 | ); |
|
974 | break; |
|
975 | case 'pcre': |
|
976 | //An older regex that doesn't need a recent PCRE |
|
977 | return (bool) preg_match( |
|
978 | '/^(?!(?>"?(?>\\\[ -~]|[^"])"?){255,})(?!(?>"?(?>\\\[ -~]|[^"])"?){65,}@)(?>'. |
|
979 | '[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*")'. |
|
980 | '(?>\.(?>[!#-\'*+\/-9=?^-~-]+|"(?>(?>[\x01-\x08\x0B\x0C\x0E-!#-\[\]-\x7F]|\\\[\x00-\xFF]))*"))*'. |
|
981 | '@(?>(?![a-z0-9-]{64,})(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)(?>\.(?![a-z0-9-]{64,})'. |
|
982 | '(?>[a-z0-9](?>[a-z0-9-]*[a-z0-9])?)){0,126}|\[(?:(?>IPv6:(?>(?>[a-f0-9]{1,4})(?>:'. |
|
983 | '[a-f0-9]{1,4}){7}|(?!(?:.*[a-f0-9][:\]]){8,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?'. |
|
984 | '::(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,6})?))|(?>(?>IPv6:(?>[a-f0-9]{1,4}(?>:'. |
|
985 | '[a-f0-9]{1,4}){5}:|(?!(?:.*[a-f0-9]:){6,})(?>[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4})?'. |
|
986 | '::(?>(?:[a-f0-9]{1,4}(?>:[a-f0-9]{1,4}){0,4}):)?))?(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}'. |
|
987 | '|[1-9]?[0-9])(?>\.(?>25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}))\])$/isD', |
|
988 | $address |
|
989 | ); |
|
990 | break; |
|
991 | case 'php': |
|
992 | default: |
|
993 | return (bool) filter_var($address, FILTER_VALIDATE_EMAIL); |