[editor] Check OSM max char length in value validation

Signed-off-by: map-per <map-per@gmx.de>
This commit is contained in:
map-per
2025-12-07 13:01:03 +01:00
committed by map-per
parent f20c3bf50c
commit f1cf844986
5 changed files with 47 additions and 7 deletions

View File

@@ -243,14 +243,11 @@ void ChangesetWrapper::Modify(editor::XMLFeature node)
void ChangesetWrapper::AddChangesetTag(std::string key, std::string value)
{
value = strings::EscapeForXML(value);
// Truncate to 254 characters as OSM has a length limit of 255
if (strings::Truncate(value, kMaximumOsmChars))
value += "";
//OSM has a length limit of 255 characters
if (value.length() > kMaximumOsmChars)
{
LOG(LWARNING, ("value is too long for OSM 255 char limit: ", value));
value = value.substr(0, kMaximumOsmChars - 3).append("...");
}
value = strings::EscapeForXML(value);
m_changesetComments.insert_or_assign(std::move(key), std::move(value));
}