# filter_var doesn't support international email addresses

- Thread: https://externals.io/message/81988
- Original archive: https://news-web.php.net/php.internals/81988
- Started by j adams on 2015-02-06T00:05:05+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #81988 — j adams — 2015-02-06T00:05:05+00:00

URL: https://externals.io/message/81988#81988

Please let me know which mailing list address to use if I have sent this to
the wrong list.

filter_var does not properly validate emails with international characters.
For example, this returns FALSE:

var_dump(filter_var("Pelé@example.com", FILTER_VALIDATE_EMAIL));

Are there any plans to implement proper validation of email addresses as
described in RFC 6530?
http://tools.ietf.org/html/rfc6530

---

## #82049 — Rowan Collins — 2015-02-06T15:14:54+00:00

URL: https://externals.io/message/81988#82049 · In reply to: #81988

j adams wrote on 06/02/2015 00:05:
> Please let me know which mailing list address to use if I have sent this to
> the wrong list.
>
> filter_var does not properly validate emails with international characters.
> For example, this returns FALSE:
>
> var_dump(filter_var("Pelé@example.com", FILTER_VALIDATE_EMAIL));
>
> Are there any plans to implement proper validation of email addresses as
> described in RFC 6530?
> http://tools.ietf.org/html/rfc6530

Hi,

There was a discussion a while back about Internationalized Domain Name 
support in `FILTER_VALIDATE_URL` [1], and I believe there was a concern 
that since not all systems would accept the wider format, allowing them 
through the existing filter might be unhelpful. This is particularly 
true in the case of internationalized e-mails, since if I understand it 
correctly it's an "all or nothing" system, rather than one with a 
compatible fallback like the "punycode" notation used in domains.

The most useful would probably be to add a new filter type which 
accepted the new format, so that users could choose to accept what they 
know they can process. If you know of or can create a succinct validity 
test (e.g. a PCRE-compatible regex) it ought to be fairly easy to add; 
the existing implementation is here for comparison: 
http://lxr.php.net/xref/PHP_TRUNK/ext/filter/logical_filters.c#575

[1] 
http://grokbase.com/t/php/php-internals/149jfzxtq3/internationalized-domain-name-support-in-filter-validate-url

Regards,
-- 
Rowan Collins
[IMSoP]

---

## #82876 — j adams — 2015-02-16T18:59:46+00:00

URL: https://externals.io/message/81988#82876 · In reply to: #82049

Rowan, thanks for your response.

Wow that regex is pretty intense. A new filter type sounds like a
reasonable idea to me. I'm not sure if I'll be able to offer any
improvements myself (although I will look into it shortly here). I I do
know that Google announced last August that they plan to support RFC6530:
http://googleblog.blogspot.com/2014/08/a-first-step-toward-more-global-email.html



On Fri, Feb 6, 2015 at 7:14 AM, Rowan Collins <rowan.collins@gmail.com>
wrote:

> j adams wrote on 06/02/2015 00:05:
>
>  Please let me know which mailing list address to use if I have sent this
> > […]
>
> Hi,
>
> There was a discussion a while back about Internationalized Domain Name
> support in `FILTER_VALIDATE_URL` [1], and I believe there was a concern that
> since not all systems would accept the wider format, allowing them through
> the existing filter might be unhelpful. This is particularly true in the
> case of internationalized e-mails, since if I understand it correctly it's
> an "all or nothing" system, rather than one with a compatible fallback like
> the "punycode" notation used in domains.
>
> The most useful would probably be to add a new filter type which accepted
> the new format, so that users could choose to accept what they know they
> can process. If you know of or can create a succinct validity test (e.g. a
> PCRE-compatible regex) it ought to be fairly easy to add; the existing
> implementation is here for comparison: http://lxr.php.net/xref/PHP_
> TRUNK/ext/filter/logical_filters.c#575
>
> [1] http://grokbase.com/t/php/php-internals/149jfzxtq3/
> internationalized-domain-name-support-in-filter-validate-url
>
> Regards,
> --
> Rowan Collins
> [IMSoP]
