diff options
author | mgsergio <mgsergio@yandex.ru> | 2016-06-29 19:10:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-06-29 19:10:59 +0300 |
commit | 5015a517216a2e8504b05c2ba2e745d44d3606c1 (patch) | |
tree | aefe96a10f212342f88f62bbcf996316b4ea8b0a /indexer/editable_map_object.cpp | |
parent | 19af6cdc39bbc1e20cb6642c577239b65f8338e8 (diff) | |
parent | d115b3343f15578ed25d420db80822db426ca4da (diff) |
Merge pull request #3687 from milchakov/MAPSME-1656_incorrect_email_validation
[editor] Mapsme 1656 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 e79685484e..d074f2255a 100644 --- a/indexer/editable_map_object.cpp +++ b/indexer/editable_map_object.cpp @@ -315,6 +315,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; @@ -323,14 +332,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 |