From 408dc2715247b6302afd8ba0b4b64d2f7d73ea63 Mon Sep 17 00:00:00 2001 From: ddpasa Date: Thu, 1 Sep 2022 17:18:14 +0200 Subject: [PATCH] [generator] Update checks for wikimedia_commons tag This tag is frequenty misused and a full url is provided. It's incorrect but happens so often that we should protect against it. Signed-off-by: ddpasa --- generator/osm2meta.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/generator/osm2meta.cpp b/generator/osm2meta.cpp index 9356a23b35..a37702c58b 100644 --- a/generator/osm2meta.cpp +++ b/generator/osm2meta.cpp @@ -289,6 +289,13 @@ string MetadataTagProcessorImpl::ValidateAndFormat_wikipedia(string v) const string MetadataTagProcessorImpl::ValidateAndFormat_wikimedia_commons(string v) const { + + // Putting the full wikimedia url to this tag is incorrect according to: + // https://wiki.openstreetmap.org/wiki/Key:wikimedia_commons + // But it happens often enough that we should guard against it. + strings::ReplaceFirst(v, "https://commons.wikimedia.org/wiki/", ""); + strings::ReplaceFirst(v, "https://commons.m.wikimedia.org/wiki/", ""); + if(strings::StartsWith(v, "File:") || strings::StartsWith(v, "Category:")) { return v;