diff --git a/src/SmtpServer.Tests/SmtpParserTests.cs b/src/SmtpServer.Tests/SmtpParserTests.cs index 555093c..62de745 100644 --- a/src/SmtpServer.Tests/SmtpParserTests.cs +++ b/src/SmtpServer.Tests/SmtpParserTests.cs @@ -102,6 +102,7 @@ public void CanNotMakeHelo(string input) [InlineData("EHLO abc-1-def.mail.com", "abc-1-def.mail.com")] [InlineData("EHLO 192.168.1.200", "192.168.1.200")] [InlineData("EHLO [192.168.1.200]", "192.168.1.200")] + [InlineData("EHLO dæmi.is", "dæmi.is")] [InlineData("EHLO [IPv6:ABCD:EF01:2345:6789:ABCD:EF01:2345:6789]", "IPv6:ABCD:EF01:2345:6789:ABCD:EF01:2345:6789")] public void CanMakeEhlo(string input, string domainOrAddress) { @@ -153,6 +154,7 @@ public void CanMakeAuthLogin() [InlineData("MAIL FROM:", "cain.osullivan", "gmail.com")] [InlineData(@"MAIL FROM:<""Abc@def""@example.com>", "Abc@def", "example.com")] [InlineData("MAIL FROM: SMTPUTF8", "pelé", "example.com", "SMTPUTF8")] + [InlineData("MAIL FROM:<þorsteinn@dæmi.is> SMTPUTF8", "þorsteinn", "dæmi.is", "SMTPUTF8")] public void CanMakeMail(string input, string user, string host, string extension = null) { // arrange @@ -226,6 +228,7 @@ public void CanNotMakeMail(string input) [InlineData("RCPT TO:", "cain.osullivan", "gmail.com")] [InlineData(@"RCPT TO:<""Abc@def""@example.com>", "Abc@def", "example.com")] [InlineData("RCPT TO:", "pelé", "example.com")] + [InlineData("RCPT TO:<þorsteinn@dæmi.is>", "þorsteinn", "dæmi.is")] [InlineData("RCPT TO:<@example1.com:someone@example.com>", "someone", "example.com")] [InlineData("RCPT TO:<@example1.com,@example2.com:someone@example.com>", "someone", "example.com")] [InlineData("RCPT TO:", "example/example", "example.com")] diff --git a/src/SmtpServer/Protocol/SmtpParser.cs b/src/SmtpServer/Protocol/SmtpParser.cs index 3b57b32..68ab70e 100644 --- a/src/SmtpServer/Protocol/SmtpParser.cs +++ b/src/SmtpServer/Protocol/SmtpParser.cs @@ -89,7 +89,7 @@ public bool TryMakeHelo(ref TokenReader reader, out SmtpCommand command, out Smt if (reader.TryMake(TryMakeDomain, out var domain)) { - command = _smtpCommandFactory.CreateHelo(StringUtil.Create(domain)); + command = _smtpCommandFactory.CreateHelo(StringUtil.Create(domain, Encoding.UTF8)); return true; } @@ -148,7 +148,7 @@ public bool TryMakeEhlo(ref TokenReader reader, out SmtpCommand command, out Smt if (reader.TryMake(TryMakeDomain, out var domain)) { - command = _smtpCommandFactory.CreateEhlo(StringUtil.Create(domain)); + command = _smtpCommandFactory.CreateEhlo(StringUtil.Create(domain, Encoding.UTF8)); return true; } @@ -1119,7 +1119,7 @@ static Mailbox CreateMailbox(ReadOnlySequence localpart, ReadOnlySequence< return null; } - var tempDomain = StringUtil.Create(domainOrAddress); + var tempDomain = StringUtil.Create(domainOrAddress, Encoding.UTF8); if (tempDomain == null) { return null;