[10/10] importer: Validate country codes from Geofeeds
Commit Message
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
src/scripts/location-importer.in | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
@@ -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("""