mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 10:22:15 -05:00
Use android.text.util.Regex.EMAIL_ADDRESS_PATTERN for email address verification before account creation.
Fixes issue 1386
This commit is contained in:
parent
0cd04a66c1
commit
96489049d9
@ -1,20 +1,11 @@
|
|||||||
|
|
||||||
package com.fsck.k9;
|
package com.fsck.k9;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import android.text.util.Rfc822Tokenizer;
|
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
|
||||||
{
|
{
|
||||||
// Source: http://www.regular-expressions.info/email.html
|
|
||||||
private static Pattern p = Pattern.compile(
|
|
||||||
"[a-z0-9!#$%&'*+/=?^_`{|}~-]+" +
|
|
||||||
"(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*" +
|
|
||||||
"@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+" +
|
|
||||||
"[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
|
|
||||||
|
|
||||||
public CharSequence fixText(CharSequence invalidText)
|
public CharSequence fixText(CharSequence invalidText)
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
@ -27,6 +18,6 @@ public class EmailAddressValidator implements Validator
|
|||||||
|
|
||||||
public boolean isValidAddressOnly(CharSequence text)
|
public boolean isValidAddressOnly(CharSequence text)
|
||||||
{
|
{
|
||||||
return p.matcher(text).matches();
|
return android.text.util.Regex.EMAIL_ADDRESS_PATTERN.matcher(text).matches();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user