Saturday, October 11, 2008

Lab 6: Thunderbird Bux Fix Lab

I found that building Thunderbird was easy enough. The challenge with this assignment was finding a regular expression that could properly match all of the following email address formats:

Eventually I realized that finding a regular expression was pointless since I wouldn't be able to actually use it, so I tried thinking of general rules that would make an email address invalid:

  1. 1. Periods can't be right next to eachother
  2. 2. An address can't end in a period
  3. 3. An address can't begin with an @
  4. 4. An address can't have a period right after the @


The next step was to find the relevant code. Using the hint given to us by Dave, I simply did a find on the word mailto and came across line 198 of the mozTXTToHTMLConv.cpp

if (inString.FindChar('.', pos) != kNotFound)
{
aOutString.AssignLiteral("mailto:");
aOutString += aInString;
}

This seemed to be the block of code that evaluated the e-mail address. I noticed that it only checked for a . right after the @ sign, so using the rules I established for a valid e-mail, I changed the if statement to this:

if (inString.FindChar('.', pos) != kNotFound && inString.Find("..", 0) == kNotFound && inString.CharAt(inString.Length() - 1) != '.')
{
aOutString.AssignLiteral("mailto:");
aOutString += aInString;
}

Now the if checks for a '.' right after the @, 2 '.' next to eachother, and a '.' in the last character of the string.

Still In Progress....

No comments: