From dd1eccfda82f086abf24c52f29102e9f051290a1 Mon Sep 17 00:00:00 2001 From: srowen Date: Sun, 15 Feb 2009 09:45:52 +0000 Subject: [PATCH] Tighten email check logic a little git-svn-id: https://zxing.googlecode.com/svn/trunk@857 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- .../client/result/EmailDoCoMoResultParser.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/src/com/google/zxing/client/result/EmailDoCoMoResultParser.java b/core/src/com/google/zxing/client/result/EmailDoCoMoResultParser.java index 6e12df042..312d65298 100644 --- a/core/src/com/google/zxing/client/result/EmailDoCoMoResultParser.java +++ b/core/src/com/google/zxing/client/result/EmailDoCoMoResultParser.java @@ -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