[PATCH] Encode timezone from GeoIP as UTF-8 string (#975159)

Martin Kolman mkolman at gmail.com
Tue Jun 18 12:55:50 UTC 2013


The Fedora GeoIP API returns the timezone in Unicode. This can cause
issues when the timezone is combined with other strings
(for example concatenated with some translated strings).
Therefore, the timezone needs to be converted
to a UTF-8 encoded string.

Signed-off-by: Martin Kolman <mkolman at gmail.com>
---
 pyanaconda/geoloc.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/pyanaconda/geoloc.py b/pyanaconda/geoloc.py
index 2fc8427..5a6da14 100644
--- a/pyanaconda/geoloc.py
+++ b/pyanaconda/geoloc.py
@@ -475,6 +475,13 @@ class FedoraGeoIPProvider(GeolocationBackend):
                 territory = json_reply.get("country_code", None)
                 timezone_source = "GeoIP"
                 timezone_code = json_reply.get("time_zone", None)
+
+                if timezone_code is not None:
+                    # the timezone code is returned as Unicode,
+                    # it needs to be converted to UTF-8 encoded string,
+                    # otherwise some string processing in Anaconda might fail
+                    timezone_code = timezone_code.encode("utf8")
+
                 # check if the timezone returned by the API is valid
                 if not timezone.is_valid_timezone(timezone_code):
                     # try to get a timezone from the territory code
-- 
1.8.1.4



More information about the anaconda-patches mailing list