Merge pull request #3720 from milchakov/MAPSME-1660_incorrect_website_validation

[editor] incorrect website validation
This commit is contained in:
mgsergio 2016-07-05 14:36:50 +04:00 committed by GitHub
commit e7915eb557
2 changed files with 10 additions and 3 deletions

View file

@ -320,9 +320,14 @@ bool EditableMapObject::ValidateWebsite(string const & site)
if (site.empty())
return true;
auto const dotPos = find(begin(site), end(site), '.');
// Site should contain at least one dot but not at the begining/and.
if (dotPos == end(site) || site.front() == '.' || site.back() == '.')
// Site should contain at least one dot but not at the begining/end.
if ('.' == site.front() || '.' == site.back())
return false;
if (string::npos == site.find("."))
return false;
if (string::npos != site.find(".."))
return false;
return true;

View file

@ -100,6 +100,8 @@ UNIT_TEST(EditableMapObject_ValidateWebsite)
TEST(!EditableMapObject::ValidateWebsite(".qwerty"), ());
TEST(!EditableMapObject::ValidateWebsite("qwerty."), ());
TEST(!EditableMapObject::ValidateWebsite(".qwerty."), ());
TEST(!EditableMapObject::ValidateWebsite(".qwerty."), ());
TEST(!EditableMapObject::ValidateWebsite("w..com"), ());
}
UNIT_TEST(EditableMapObject_ValidateEmail)