r75876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75875‎ | r75876 | r75877 >
Date:20:39, 2 November 2010
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
Fix misinterpration of HTML5 specification for email validation.
Follow up: r75670 (JS), r75682 (PHP)
Modified paths:
  • /trunk/phase3/includes/User.php (modified) (history)
  • /trunk/phase3/maintenance/tests/phpunit/includes/UserIsValidEmailAddrTest.php (modified) (history)
  • /trunk/phase3/resources/mediawiki.specials/mediawiki.specials.preferences.js (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/phpunit/includes/UserIsValidEmailAddrTest.php
@@ -27,7 +27,8 @@
2828 $this->valid( 'USER@eXAMPLE.com' );
2929 }
3030 function testEmailWithAPlusInUserName() {
31 - $this->valid( 'user+sub@localdomain' );
 31+ $this->valid( 'user+sub@example.com' );
 32+ $this->valid( 'user+@example.com' );
3233 }
3334 function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
3435 $this->invalid( " user@host" );
@@ -43,10 +44,10 @@
4445 function testEmailDomainCanNotBeginWithDot() {
4546 $this->invalid( "user@." );
4647 $this->invalid( "user@.localdomain" );
47 - $this->valid( "user@localdomain." );
48 - $this->valid( "user.@localdomain" );
49 - $this->valid( ".@localdomain" );
50 - $this->valid( ".@a............" );
 48+ $this->invalid( "user@localdomain." );
 49+ $this->invalid( "user.@localdomain" );
 50+ $this->invalid( ".@localdomain" );
 51+ $this->invalid( ".@a............" );
5152 }
5253 function testEmailWithFunnyCharacters() {
5354 $this->valid( "\$user!ex{this}@123.com" );
Index: trunk/phase3/includes/User.php
@@ -655,8 +655,8 @@
656656 ^ # start of string
657657 [$rfc5322_atext\\.]+ # user part which is liberal :p
658658 @ # 'apostrophe'
659 - [$rfc1034_ldh_str] # Domain first character
660 - [$rfc1034_ldh_str\\.]+ # Second char and following can include dot
 659+ [$rfc1034_ldh_str]+ # First domain part
 660+ (\\.[$rfc1034_ldh_str]+)+ # Following part prefixed with a dot
661661 $ # End of string
662662 /ix" ; // case Insensitive, eXtended
663663
Index: trunk/phase3/resources/mediawiki.specials/mediawiki.specials.preferences.js
@@ -112,11 +112,11 @@
113113 // "apostrophe"
114114 '@'
115115 +
116 - // Domain first character
117 - '[' + rfc1034_ldh_str + ']'
 116+ // Domain first part
 117+ '[' + rfc1034_ldh_str + ']+'
118118 +
119 - // second char and following can include dot
120 - '[' + rfc1034_ldh_str + '\\.' + ']' + '+'
 119+ // Second part and following are separated by a dot
 120+ '(\\.[' + rfc1034_ldh_str + ']+)+'
121121 +
122122 // End of string
123123 '$',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r75670Follow up r75627 (code review comments):...hashar20:44, 29 October 2010
r75682Follow up r75627. Implements r75670 in PHP to validate emails....hashar22:03, 29 October 2010

Comments

#Comment by Werdna (talk | contribs)   03:24, 28 November 2010

This rejects valid email addresses such as andrew@localhost

They may not be valid for web sites, but people use MediaWiki on intranets too!

#Comment by Hashar (talk | contribs)   14:12, 28 November 2010
#Comment by Reedy (talk | contribs)   22:03, 6 January 2011

Can we resolve this or whatever, and just make sure there is a bug to come back to to "fix" this later?

Same for the 2 revisions this follows up?

#Comment by Reedy (talk | contribs)   19:30, 7 January 2011

Marking as resolved, added upstream and remote bug on bug 22449

Status & tagging log