diff options
author | Arsentiy Milchakov <a.milchakov@corp.mail.ru> | 2016-06-29 18:56:52 +0300 |
---|---|---|
committer | Arsentiy Milchakov <a.milchakov@corp.mail.ru> | 2016-06-29 18:56:52 +0300 |
commit | d115b3343f15578ed25d420db80822db426ca4da (patch) | |
tree | 034a00464f7152326f0551a90dd06bc328ad0f7e /indexer/editable_map_object.cpp | |
parent | cd6395349a25803dfbee006001eea5939ec15ec9 (diff) |
Fix incorrect email validation
Diffstat (limited to 'indexer/editable_map_object.cpp')
-rw-r--r-- | indexer/editable_map_object.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/indexer/editable_map_object.cpp b/indexer/editable_map_object.cpp index db2c5c760a..14ae7c01c1 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -312,6 +312,15 @@ bool EditableMapObject::ValidateEmail(string const & email) if (email.empty()) return true; + if (strings::IsASCIIString(email)) + return regex_match(email, regex(R"([^@\s]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$)")); + + if ('@' == email.front() || '@' == email.back()) + return false; + + if ('.' == email.back()) + return false; + auto const atPos = find(begin(email), end(email), '@'); if (atPos == end(email)) return false; @@ -320,14 +329,10 @@ bool EditableMapObject::ValidateEmail(string const & email) if (find(next(atPos), end(email), '@') != end(email)) return false; - // There should be at least one '.' sign after '@' ... + // There should be at least one '.' sign after '@' if (find(next(atPos), end(email), '.') == end(email)) return false; - // ... not in the end. - if (email.back() == '.') - return false; - return true; } } // namespace osm |