From 525006daea9fbf43dcb5f904eefea573bae0a9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Mat=C3=ADas=20S=C3=A1nchez=20=28Quique=29?= Date: Tue, 7 Mar 2017 11:19:33 +0100 Subject: [PATCH] Fix email maximum length: an entire email address can be up to 254 characters long. See RFC 3696 erratum 1690: https://www.rfc-editor.org/errata_search.php?eid=1690 There is a restriction in RFC 2821 on the length of an address in MAIL and RCPT commands of 254 characters. Since addresses that do not fit in those fields are not normally useful, the upper limit on address lengths should normally be considered to be 254. --- .../m170307_100221_update_email_type.php | 29 +++++++++++++++++++ migrations/mysql.schema.sql | 2 +- views/auth/confirmEmail.php | 2 +- views/auth/passwordRecovery.php | 2 +- views/user/_form.php | 4 +-- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 migrations/m170307_100221_update_email_type.php diff --git a/migrations/m170307_100221_update_email_type.php b/migrations/m170307_100221_update_email_type.php new file mode 100644 index 00000000..9acbab96 --- /dev/null +++ b/migrations/m170307_100221_update_email_type.php @@ -0,0 +1,29 @@ +alterColumn('user', 'email', 'varchar(254)'); + } + + public function down() + { + echo "m170307_100221_update_email_type cannot be reverted.\n"; + + return false; + } + + /* + // Use safeUp/safeDown to run migration code within a transaction + public function safeUp() + { + } + + public function safeDown() + { + } + */ +} diff --git a/migrations/mysql.schema.sql b/migrations/mysql.schema.sql index 1e83df31..98b5ee1f 100644 --- a/migrations/mysql.schema.sql +++ b/migrations/mysql.schema.sql @@ -280,7 +280,7 @@ CREATE TABLE IF NOT EXISTS `user` ( `updated_at` int(11) NOT NULL, `registration_ip` varchar(15) DEFAULT NULL, `bind_to_ip` varchar(255) DEFAULT NULL, - `email` varchar(128) DEFAULT NULL, + `email` varchar(254) DEFAULT NULL, `email_confirmed` smallint(1) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; diff --git a/views/auth/confirmEmail.php b/views/auth/confirmEmail.php index c21d1978..42d1a23d 100644 --- a/views/auth/confirmEmail.php +++ b/views/auth/confirmEmail.php @@ -34,7 +34,7 @@ 'validateOnBlur'=>false, ]); ?> - field($model, 'email')->textInput(['maxlength' => 255, 'autofocus'=>true]) ?> + field($model, 'email')->textInput(['maxlength' => 254, 'autofocus'=>true]) ?>
diff --git a/views/auth/passwordRecovery.php b/views/auth/passwordRecovery.php index b834c6d0..c68b7818 100644 --- a/views/auth/passwordRecovery.php +++ b/views/auth/passwordRecovery.php @@ -30,7 +30,7 @@ 'validateOnBlur'=>false, ]); ?> - field($model, 'email')->textInput(['maxlength' => 255, 'autofocus'=>true]) ?> + field($model, 'email')->textInput(['maxlength' => 254, 'autofocus'=>true]) ?> field($model, 'captcha')->widget(Captcha::className(), [ 'template' => '
{image}
{input}
', diff --git a/views/user/_form.php b/views/user/_form.php index e828d60f..4736ff75 100644 --- a/views/user/_form.php +++ b/views/user/_form.php @@ -44,7 +44,7 @@ - field($model, 'email')->textInput(['maxlength' => 255]) ?> + field($model, 'email')->textInput(['maxlength' => 254]) ?> field($model, 'email_confirmed')->checkbox() ?> @@ -70,4 +70,4 @@
- \ No newline at end of file +