[PATCH] Encode timezone from GeoIP as UTF-8 string (#975159)
Vratislav Podzimek
vpodzime at redhat.com
Tue Jun 18 12:58:42 UTC 2013
On Tue, 2013-06-18 at 14:55 +0200, Martin Kolman wrote:
> 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
ACK, we do the same with the timezones returned by the pytz module.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list