Saturday, October 31, 2009

Thunderbird Bug fixed !! :)

hey,..
despite the failure and frustration that i faced, during my several attempts to build the thunderbird project,the idea of me getting a sight into the project's code never vanished completely. :)
Through the code search agent MXR (here) i managed to take a look into the code.The MXR is a code search enginr that understands the semantics of your query (more or less =) ) . Anyway, Thunderbird suffers from a serious bug,while typing in the mail editor,the " automated hyperlink detector" mis interperts some of the written text.
For example,writing " S@Y...where" would be interpreted as a valid mail address. This is a brief description for the problem, a more detailed one could be found here.
Using MXR the following code segment was found and was observed to be of special interest to solve the bug mentioned above:
 if (aInString[pos] == '@')
195 {
196 // only pre-pend a mailto url if the string contains a .domain in it..
197 //i.e. we want to linkify johndoe@foo.com but not "let's meet @8pm"
198 nsDependentString inString(aInString, aInLength);
199 if (inString.FindChar('.', pos) != kNotFound) // if we have a '.' after the @ sign....
200 {
201 aOutString.AssignLiteral("mailto:");
202 aOutString += aInString;
203 }
204 }

Clearly the code doesn't handle the special cases as the one mentioned above.
So,as part of my this week's assignment,as well as part of my duty towards the open source comunity ( :D ) modification to the current code segment had to be implemented.
The following modification was the result of some searching problem solving techniques:
Substituding line 199 in the previous code with :

if ((pos!=0)&& (inString.CharAt(pos+1)!='.') && (inString.CharAt(inString.length()-1)!='.') (inString.FindChar('.', pos) != kNotFound) && (inString.Find("..",0)==kNotFound))

As it is obvious,each condition handles different case.
1.pos!=0: An email address cannot start with the "@" symbol
2. inString.CharAt(pos+1)!='.' : An email address cannot have a dot right after the @ symbol
3.inString.CharAt(inString.length()-1)!='.': An email address cannot end with a dot.
4.inString.FindChar('.', pos) != kNotFound : An email must contain at least one dot(but not in the previous positions)
5. inString.Find("..",0)==kNotFound : An email address cannot contain two consecutive dots.

The previous modification was developed with the help of the c++ tutorial that could be found here . (as i am no c++ expert myself :) )

Unfortunately,i wasn't able to patch my modification,and get it reviewed,since i failed to build thunderbird for this reason.
Hopefully,the problem with building will be solved,and i will tell you all about it in my next post :)
Cheers,
Mina

No comments:

Post a Comment