| Index: chrome/browser/autofill/personal_data_manager.cc
|
| diff --git a/chrome/browser/autofill/personal_data_manager.cc b/chrome/browser/autofill/personal_data_manager.cc
|
| index ac33ca24afbba7bb9a815588e4588c14bb80a17c..8430b15a49594eb1ee174cf069020b70f315837a 100644
|
| --- a/chrome/browser/autofill/personal_data_manager.cc
|
| +++ b/chrome/browser/autofill/personal_data_manager.cc
|
| @@ -19,6 +19,8 @@
|
| #include "chrome/browser/webdata/web_data_service.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/common/pref_names.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebRegularExpression.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
|
|
|
| namespace {
|
|
|
| @@ -69,6 +71,16 @@ T* address_of(T& v) {
|
| return &v;
|
| }
|
|
|
| +bool IsValidEmail(const string16& value) {
|
| + // This regex is more permissive than the official rfc2822 spec on the
|
| + // subject, but it does reject obvious non-email addresses.
|
| + const string16 kEmailPattern =
|
| + ASCIIToUTF16("^[^@]+@[^@]+\\.[a-z]{2,6}$");
|
| + WebKit::WebRegularExpression re(WebKit::WebString(kEmailPattern),
|
| + WebKit::WebTextCaseInsensitive);
|
| + return re.match(WebKit::WebString(StringToLowerASCII(value))) != -1;
|
| +}
|
| +
|
| // Returns true if minimum requirements for import of a given |profile| have
|
| // been met. An address submitted via a form must have at least these fields
|
| // filled. No verification of validity of the contents is preformed. This is
|
| @@ -231,6 +243,9 @@ bool PersonalDataManager::ImportFormData(
|
| }
|
| }
|
|
|
| + if (field_type.field_type() == EMAIL_ADDRESS && !IsValidEmail(value))
|
| + continue;
|
| +
|
| imported_profile_->SetInfo(AutoFillType(field_type.field_type()),
|
| value);
|
| ++importable_fields;
|
|
|