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

Bug: Email->validateEmail() on wrong email address leads to TypeError #2580

Closed
bivanbi opened this issue Feb 20, 2020 · 2 comments
Closed

Bug: Email->validateEmail() on wrong email address leads to TypeError #2580

bivanbi opened this issue Feb 20, 2020 · 2 comments
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@bivanbi
Copy link
Contributor

bivanbi commented Feb 20, 2020

Direction
We use github issues to track bugs, not for support.
If you have a support question, or a feature request, raise these as threads on our
forum.

Describe the bug
CodeIgniter\Email\Email class validateEmail() method line 919:
When validation is enabled and an invalid e-mail address is passed to Email class, validateEmail() tries to call lang() helper with string (the e-mail address being validated) as second parameter:

$this->setErrorMessage(lang('Email.invalidAddress', $val));

system/Common.php lang() method signature only accepts array as second parameter:

function lang(string $line, array $args = [], string $locale = null)

This eventually leads to TypeError.

CodeIgniter 4 version
4.0.0rc3
develop @ dfd3555

Affected module(s)
CodeIgniter\Email\Email class
and/or
system/Common.php

Expected behavior, and steps to reproduce if appropriate
To reproduce, create a simple test case:

class EmailTest extends CIUnitTestCase
{
    public function testEmailValidation()
    {
        $config = config('Email');
        $config->validate = true;
        $email = new \CodeIgniter\Email\Email($config);
        $email->setTo('invalid');
        $this->assertStringContainsString('Invalid email address: invalid', $email->printDebugger());
    }
}

Expected:
Test passes
Actual:

  1. Tests\EmailTest::testEmailValidation
    TypeError: Argument 2 passed to lang() must be of the type array, string given, called in system/Email/Email.php on line 919

Context

  • OS: [Linux]
  • Web server [Apache + PHP-FPM 7.2]
  • PHP version [7.2]
@bivanbi bivanbi added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 20, 2020
@musmanikram
Copy link
Contributor

working on it

@MGatner
Copy link
Member

MGatner commented Feb 21, 2020

Thanks @musmanikram!

@MGatner MGatner closed this as completed Feb 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

No branches or pull requests

3 participants