1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-04 08:35:08 -05:00

I broke email address validation with r1447. I changed EmailAddressValidator.isValid() to only accept email addresses without name part ('foo@bar.com' but not '"snafu" foo@bar.com') because AccountSetupBasics used it to verify the email address for an account. With the old validator spaces were allowed in the email field but lead to an exception later (issue 849). Unfortunately I missed the fact that there are implicit calls to isValid() to validate email addresses e.g. in the 'To field

This commit is contained in:
cketti 2010-02-15 12:51:38 +00:00
parent e6cabe4a82
commit f7094a2a8e
2 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package com.fsck.k9;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import android.text.util.Rfc822Tokenizer;
import android.widget.AutoCompleteTextView.Validator; import android.widget.AutoCompleteTextView.Validator;
public class EmailAddressValidator implements Validator public class EmailAddressValidator implements Validator
@ -20,6 +21,11 @@ public class EmailAddressValidator implements Validator
} }
public boolean isValid(CharSequence text) public boolean isValid(CharSequence text)
{
return Rfc822Tokenizer.tokenize(text).length > 0;
}
public boolean isValidAddressOnly(CharSequence text)
{ {
return p.matcher(text).matches(); return p.matcher(text).matches();
} }

View File

@ -133,7 +133,7 @@ public class AccountSetupBasics extends K9Activity
String email = mEmailView.getText().toString(); String email = mEmailView.getText().toString();
boolean valid = Utility.requiredFieldValid(mEmailView) boolean valid = Utility.requiredFieldValid(mEmailView)
&& Utility.requiredFieldValid(mPasswordView) && Utility.requiredFieldValid(mPasswordView)
&& mEmailValidator.isValid(email); && mEmailValidator.isValidAddressOnly(email);
mNextButton.setEnabled(valid); mNextButton.setEnabled(valid);
mManualSetupButton.setEnabled(valid); mManualSetupButton.setEnabled(valid);