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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing non-breaking space is valid? #358

Open
dmaicher opened this issue Jan 23, 2023 · 1 comment
Open

Trailing non-breaking space is valid? #358

dmaicher opened this issue Jan 23, 2023 · 1 comment
Labels

Comments

@dmaicher
Copy link

First of all thanks for maintaining this nice library 馃憤

I'm using it on my Symfony app in strict mode (which uses NoRFCWarningsValidation).

I noticed from time to time my postfix service on prod has some issues with email addresses that passed the validation. In those cases I have trailing non-breaking spaces.

I'm not that familiar with all the RFC specs out there around email address syntax 馃構

So I'm wondering: should those be valid? 馃

Reproducer:

<?php

require_once 'vendor/autoload.php';

use Egulias\EmailValidator\EmailValidator;
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;

$validator = new EmailValidator();

var_dump($validator->isValid('some@email.com'.mb_chr(0xA0), new NoRFCWarningsValidation())); //true

var_dump($validator->isValid('some@email.com ', new NoRFCWarningsValidation())); // false
@egulias
Copy link
Owner

egulias commented Jan 26, 2023

Hi @dmaicher
I'll look into it, seem to have to do with how mb_chr(0xA0) is interpreted, since a "normal" space is being handled correctly (returns false, per your example).
Meanwhile, a simple sanitation using trim should do the trick to remove those cases.

@egulias egulias added the bug label Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants