Tighten email check logic a little
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 15 Feb 2009 09:45:52 +0000 (09:45 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 15 Feb 2009 09:45:52 +0000 (09:45 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@857 59b500cc-1b3d-0410-9834-0bbf25fbcc57

core/src/com/google/zxing/client/result/EmailDoCoMoResultParser.java

index 6e12df0..312d652 100644 (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;
   }
 
 }
\ No newline at end of file