From: Michael Tremer Date: Tue, 27 Sep 2022 08:49:56 +0000 (+0000) Subject: importer: Validate country codes from Geofeeds X-Git-Tag: 0.9.17~29^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=72908243332d06713a93d9f7c5019c11097b3d33;p=people%2Fms%2Flibloc.git importer: Validate country codes from Geofeeds Signed-off-by: Michael Tremer --- diff --git a/src/scripts/location-importer.in b/src/scripts/location-importer.in index d0384b5..d8f9cbf 100644 --- a/src/scripts/location-importer.in +++ b/src/scripts/location-importer.in @@ -1421,7 +1421,15 @@ class CLI(object): log.debug("Could not parse network: %s" % network) continue - # XXX Check the country code + # Strip any excess whitespace from country codes + if country: + country = country.strip() + + # Check the country code + if not location.country_code_is_valid(country): + log.warning("Invalid country code in Geofeed %s: %s" \ + % (geofeed.url, country)) + continue # Write this into the database self.db.execute("""