Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormgsergio <mgsergio@yandex.ru>2016-06-29 19:10:59 +0300
committerGitHub <noreply@github.com>2016-06-29 19:10:59 +0300
commit5015a517216a2e8504b05c2ba2e745d44d3606c1 (patch)
treeaefe96a10f212342f88f62bbcf996316b4ea8b0a /indexer/editable_map_object.cpp
parent19af6cdc39bbc1e20cb6642c577239b65f8338e8 (diff)
parentd115b3343f15578ed25d420db80822db426ca4da (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.cpp15
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