Skip to content

Stackoverflowexception #21

@Daniellait

Description

@Daniellait

While trying to fetch mails from an inbox, I got a stackoverflowexception.
By using memorydump and dotpeek on your dlls, I found the following:
public static Address ParseAddress(string input)
{
Address address = new Address();
input = input.TrimEnd(';');
try
{
if (input.IndexOf("<") == -1)
{
address.Email = Parser.RemoveWhiteSpaces(input);
}
else
{
if (input.IndexOf(""") >= 0)
{
string oldValue = Regex.Match(input, ""."").Value;
address.Email = input.Replace(oldValue, "").Trim().TrimStart('<').TrimEnd('>');
address.Name = oldValue;
if (address.Email == "" && address.Name != "")
{
address.Email = address.Name;
address.Name = "";
}
}
else
{
address.Email = Regex.Match(input, "<(.|[.])
>").Value.TrimStart('<').TrimEnd('>');
address.Name = input.Replace("<" + address.Email + ">", "");
}
address.Email = Parser.Clean(Parser.RemoveWhiteSpaces(address.Email)).Replace(""", "");
if (address.Name.IndexOf(""") == -1)
address.Name = Parser.Clean(address.Name);
address.Name = address.Name.Trim(' ', '"');
}
return address;
}
catch
{
return new Address(input);
}
}

The input is the mail, which results in the error. The input is: "" Invoice@dymak.nl". This looks wrong yes, but this is not the problem.
The oldValue will now not have a length, and the try will fail. We therefor gets to catch, which calls the Address method again, with the same input. This will continue until stackoverflow has been reached.
So can you fix this, so it doesn't run in circles indefinitely, but handles the error?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions