Tighten email check logic a little

git-svn-id: https://zxing.googlecode.com/svn/trunk@857 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
srowen 2009-02-15 09:45:52 +00:00
parent 8e18d651bb
commit dd1eccfda8

View file

@ -55,8 +55,20 @@ final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
if (email == null) {
return false;
}
int atIndex = email.indexOf('@');
return atIndex >= 0 && email.indexOf('.') > atIndex && email.indexOf(' ') < 0;
boolean atFound = false;
for (int i = 0; i < email.length(); i++) {
char c = email.charAt(i);
if (c == '@') {
atFound = true;
} else if (c == '.') {
if (!atFound) {
return false;
}
} else if (c == ' ' || c == '\n') {
return false;
}
}
return true;
}
}