Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] Mail: allow domains as domain.edu.co #4905

Merged
merged 5 commits into from
Oct 25, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libraries/joomla/form/rule/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function test(SimpleXMLElement $element, $value, $group = null, JRegistry

if ($tld)
{
$this->regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]{2,})$';
$this->regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both regex a same now!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost but not quite - look at the final few characters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// Determine if the multiple attribute is present
Expand Down
2 changes: 1 addition & 1 deletion media/system/js/validate-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ var JFormValidator = function() {
});
setHandler('email', function(value) {
value = punycode.toASCII(value);
regex = /^[a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]{2,})$/;
regex = /^[a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
return regex.test(value);
});
// Attach to forms with class 'form-validate'
Expand Down
2 changes: 1 addition & 1 deletion media/system/js/validate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 19 additions & 17 deletions tests/unit/suites/libraries/joomla/form/rule/JFormRuleEmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,33 @@
class JFormRuleEmailTest extends TestCase
{
/**
* Test the JFormRuleEmail::test method.
* Test if a valid EMail is accepted by the JFormRuleEmail::test method.
*
* @return void
*/
public function testEmail()
public function testValidEmail()
{
$rule = new JFormRuleEmail;
$xml = simplexml_load_string('<form><field name="email1" /><field name="email2" unique="true" /></form>');

// Test fail conditions.

$this->assertThat(
$rule->test($xml->field[0], 'bogus'),
$this->isFalse(),
'Line:' . __LINE__ . ' The rule should fail and return false.'
);
$this->assertTrue($rule->test($xml->field[0], '[email protected]'));
}

// Test pass conditions.
/**
* Test if an invalid Email result in false for the testing method JFormRuleEmail::test method.
*
* @return void
*/
public function testAnInvalidEmail()
{
$rule = new JFormRuleEmail;
$xml = simplexml_load_string('<form><field name="email1" /><field name="email2" unique="true" /></form>');

$this->assertThat(
$rule->test($xml->field[0], '[email protected]'),
$this->isTrue(),
'Line:' . __LINE__ . ' The basic rule should pass and return true.'
);
// Test fail conditions.
$this->assertFalse($rule->test($xml->field[0], 'ThisIsNotALoveSong'));
}


/**
* Data Provider for email rule test with no multiple attribute and no tld attribute
*
Expand Down Expand Up @@ -125,6 +126,7 @@ public function testEmailData2($emailAddress, $expectedResult)
$emailAddress . ' should have returned ' . ($expectedResult ? 'true' : 'false') . ' but did not'
);
}

/**
* Data Provider for email rule test with tld attribute
*
Expand All @@ -136,8 +138,8 @@ public function emailData3()
{
return array(
array('[email protected]', true),
array('test3@localhost', false),
array('[email protected]', false),
array('test3@localhost', true),
array('[email protected]', true),
array('[email protected]', true),
array('[email protected]', true),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ public function dataIsEmailAddress()
array("[email protected]", false),
array("joe<>[email protected]", false),
array("joe&[email protected]", true),
array("[email protected]", true),
array("[email protected]", true),
array("[email protected]", false),
array("[email protected]", true),
Expand Down