mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 05:13:58 +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:
@@ -408,6 +408,10 @@ bool ValidateWebsite(string const & site)
|
||||
|
||||
auto const startPos = GetProtocolNameLength(site);
|
||||
|
||||
// check lengt and leave room for addition of 'http://'
|
||||
if (strings::CountChar(site) > (IsProtocolSpecified(site) ? kMaximumOsmChars : kMaximumOsmChars - 7))
|
||||
return false;
|
||||
|
||||
if (startPos >= site.size())
|
||||
return false;
|
||||
|
||||
@@ -429,6 +433,9 @@ bool ValidateFacebookPage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
// Check if 'page' contains valid Facebook username or page name.
|
||||
// * length >= 5
|
||||
// * no forbidden symbols in the string
|
||||
@@ -452,6 +459,9 @@ bool ValidateInstagramPage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
// Rules are defined here: https://blog.jstassen.com/2016/03/code-regex-for-instagram-username-and-hashtags/
|
||||
if (regex_match(page, s_instaRegex))
|
||||
return true;
|
||||
@@ -468,6 +478,9 @@ bool ValidateTwitterPage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
if (!ValidateWebsite(page))
|
||||
return regex_match(page, s_twitterRegex); // Rules are defined here: https://stackoverflow.com/q/11361044
|
||||
|
||||
@@ -480,6 +493,9 @@ bool ValidateVkPage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
{
|
||||
// Check that page contains valid username. Rules took here: https://vk.com/faq18038
|
||||
// The page name must be between 5 and 32 characters.
|
||||
@@ -513,6 +529,9 @@ bool ValidateLinePage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
{
|
||||
// Check that linePage contains valid page name.
|
||||
// Rules are defined here: https://help.line.me/line/?contentId=10009904
|
||||
@@ -536,6 +555,9 @@ bool ValidateFediversePage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
// Match @username@instance.name format
|
||||
if (regex_match(page, s_fediverseRegex))
|
||||
return true;
|
||||
@@ -575,6 +597,9 @@ bool ValidateBlueskyPage(string const & page)
|
||||
if (page.empty())
|
||||
return true;
|
||||
|
||||
if (strings::CountChar(page) > kMaximumOsmChars)
|
||||
return false;
|
||||
|
||||
// Match {@?}{user/domain.name} format
|
||||
if (regex_match(page, s_blueskyRegex))
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user