mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
[editor] Check OSM max char length in value validation
Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
@@ -479,6 +479,9 @@ bool EditableMapObject::CheckHouseNumberWhenIsAddress() const
|
||||
// static
|
||||
bool EditableMapObject::ValidateFlats(string const & flats)
|
||||
{
|
||||
if (strings::CountChar(flats) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
for (auto it = strings::SimpleTokenizer(flats, ";"); it; ++it)
|
||||
{
|
||||
string_view token = *it;
|
||||
@@ -516,6 +519,9 @@ bool EditableMapObject::ValidatePhoneList(string const & phone)
|
||||
if (phone.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(phone) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
auto constexpr kMaxNumberLen = 15;
|
||||
auto constexpr kMinNumberLen = 5;
|
||||
|
||||
@@ -556,6 +562,9 @@ bool EditableMapObject::ValidateEmail(string const & email)
|
||||
if (email.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(email) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
if (strings::IsASCIIString(email))
|
||||
{
|
||||
static auto const s_emailRegex = regex(R"([^@\s]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$)");
|
||||
@@ -589,6 +598,9 @@ bool EditableMapObject::ValidateLevel(string const & level)
|
||||
if (level.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(level) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
if (level.front() == ';' || level.back() == ';' || level.find(";;") != std::string::npos)
|
||||
return false;
|
||||
|
||||
@@ -633,6 +645,9 @@ bool EditableMapObject::ValidateName(string const & name)
|
||||
if (name.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(name) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
static std::u32string_view constexpr excludedSymbols = U"^§><*=_±√•÷×¶";
|
||||
|
||||
using Iter = utf8::unchecked::iterator<string::const_iterator>;
|
||||
|
||||
Reference in New Issue
Block a user