Skip to content

Commit

Permalink
Max email length is 254 chars, Fixes #4011
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed Jul 12, 2011
1 parent 8f07118 commit 986fb47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions classes/kohana/valid.php
Expand Up @@ -109,6 +109,11 @@ public static function equals($value, $required)
*/
public static function email($email, $strict = FALSE)
{
if (utf8::strlen($email) > 254)
{
return false;
}

if ($strict === TRUE)
{
$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
Expand Down
2 changes: 2 additions & 0 deletions tests/kohana/ValidTest.php
Expand Up @@ -400,6 +400,8 @@ public function provider_email()
array('foo@bar.sub.com', FALSE, TRUE),
array('foo+asd@bar.sub.com', FALSE, TRUE),
array('foo.asd@bar.sub.com', FALSE, TRUE),
// RFC says 254 length max #4011
array(text::random(NULL, 200).'@'.text::random(NULL, 50).'.com', FALSE, FALSE),
// Empty test
array('', TRUE, FALSE),
array(NULL, TRUE, FALSE),
Expand Down

0 comments on commit 986fb47

Please sign in to comment.