idn.rb 381 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class EmailHelper::Idn
  3. def self.to_ascii(address)
  4. if address =~ %r{@([^>\s]+)}
  5. address.sub!($1, SimpleIDN.to_ascii($1))
  6. end
  7. address
  8. end
  9. def self.to_unicode(address)
  10. if address =~ %r{@([\w.-]+)}
  11. address.sub!($1, SimpleIDN.to_unicode($1))
  12. end
  13. address
  14. end
  15. end