Menu

#34 Fix false positive when searching for user alias and email

Unstable (example)
closed-fixed
nobody
None
5
2018-01-09
2014-06-20
No

The following code from the getEmailAndAliasFromOptions method has a bug that manifests itself in my case:

while ((line = optionsPageReader.readLine()) != null
        && (line.indexOf('[') == -1
        || line.indexOf('@') == -1
        || line.indexOf(']') == -1)
        && !line.toLowerCase().contains(MAILBOX_BASE)) {
}

In my case, the loop ends by the second condition only:

        && (line.indexOf('[') == -1
        || line.indexOf('@') == -1
        || line.indexOf(']') == -1)

Later lastIndexOf method returns -1 in the following code:

    int start = line.toLowerCase().lastIndexOf(MAILBOX_BASE) + MAILBOX_BASE.length();

So the above loop should look like this:

while ((line = optionsPageReader.readLine()) != null
       && (line.indexOf('[') == -1
           || line.indexOf('@') == -1
           || line.indexOf(']') == -1
           || !line.toLowerCase().contains(MAILBOX_BASE))) {
}

The appropriate patch is attached.

1 Attachments

Discussion

  • Mickael Guessant

    Makes sense, patch merged.

    Thanks for your feedback,

     
  • Mickael Guessant

    • status: open --> closed-fixed
     

Log in to post a comment.