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

ACE representation of email address with IDN considered invalid #87

Closed
manuelmeurer opened this issue Nov 9, 2022 · 6 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@manuelmeurer
Copy link

manuelmeurer commented Nov 9, 2022

When I enter an email with an IDN like "test@umläut.com" in a form in my Rails app and submit it, the backend receives the ACE representation "test@xn--umlut-ira.com", which is considered invalid by email_validator in strict mode:

EmailValidator.default_options[:mode] = :strict

> EmailValidator.valid?("test@xn--umlut-ira.com")
false

> EmailValidator.valid?("test@umläut.com")
true

Is this a bug?

@manuelmeurer manuelmeurer changed the title ACE representation of IDN considered invalid ACE representation of email address with IDN considered invalid Nov 9, 2022
@karlwilbur
Copy link
Member

karlwilbur commented Nov 9, 2022

Yeah, I see what you are saying. International Domain Names (IDN), when ASCII-Compatible Encoded (ACE), are getting double dashes in them. I think that is why they are getting rejected in strict mode.

@karlwilbur
Copy link
Member

karlwilbur commented Nov 9, 2022

https://github.com/K-and-R/email_validator/blob/develop/lib/email_validator.rb#L126-L128

I expected GitHub this to include the lines of code (below) just by adding in the link to them (above). It did not, so here they are:

    def label_contains_no_more_than_one_consecutive_hyphen
      '(?!.*?--.*$)'
    end

@karlwilbur
Copy link
Member

So, this behavior is very much intentional, but may be a mistake. Let me look at the RFC again.

@karlwilbur
Copy link
Member

So, I am thinking that rejecting consecutive hyphens was my mistake. I cannot see where they are not allowed in domain names.

I do see that India's Domain Registration Service does say that:

Two hyphens together is usually not permitted and also hyphens cannot appear at both third and fourth positions.

In fact, RFC 3696 clearly indicates that double hyphens preceded by "xn" should be expected.
(https://www.rfc-editor.org/rfc/rfc3696#section-5)

So, definitely a bug.

Thank you for bringing it to my attention.

@karlwilbur karlwilbur self-assigned this Nov 9, 2022
@karlwilbur karlwilbur added the bug Something isn't working label Nov 9, 2022
@karlwilbur
Copy link
Member

@manuelmeurer Fixed in version 2.2.4

@manuelmeurer
Copy link
Author

Brilliant, thanks so much for the quick fix! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants