A fixed fix for email parsing
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 15 Feb 2009 12:00:52 +0000 (12:00 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Sun, 15 Feb 2009 12:00:52 +0000 (12:00 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@858 59b500cc-1b3d-0410-9834-0bbf25fbcc57

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

index 312d652..4f4c5c2 100644 (file)
@@ -47,7 +47,7 @@ final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
 
   /**
    * This implements only the most basic checking for an email address's validity -- that it contains
-   * an '@' and a '.' somewhere after that, and that it contains no space.
+   * an '@' and a '.', and that it contains no space or LF.
    * We want to generally be lenient here since this class is only intended to encapsulate what's
    * in a barcode, not "judge" it.
    */
@@ -56,19 +56,18 @@ final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
       return false;
     }
     boolean atFound = false;
+    boolean periodFound = 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;
-        }
+        periodFound = true;
       } else if (c == ' ' || c == '\n') {
         return false;
       }
     }
-    return true;
+    return atFound && periodFound;
   }
 
 }
\ No newline at end of file
index d741de6..d8172b4 100644 (file)
@@ -45,8 +45,6 @@ public abstract class ResultParser {
       return result;
     } else if ((result = EmailDoCoMoResultParser.parse(theResult)) != null) {
       return result;
-    } else if ((result = EmailAddressResultParser.parse(theResult)) != null) {
-      return result;
     } else if ((result = AddressBookAUResultParser.parse(theResult)) != null) {
       return result;
     } else if ((result = VCardResultParser.parse(theResult)) != null) {
@@ -55,6 +53,8 @@ public abstract class ResultParser {
       return result;
     } else if ((result = VEventResultParser.parse(theResult)) != null) {
       return result;
+    } else if ((result = EmailAddressResultParser.parse(theResult)) != null) {
+      return result;
     } else if ((result = TelResultParser.parse(theResult)) != null) {
       return result;
     } else if ((result = SMSMMSResultParser.parse(theResult)) != null) {