[geocode-glib] location: Unescape geo uri description
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib] location: Unescape geo uri description
- Date: Mon, 20 Oct 2014 17:44:34 +0000 (UTC)
commit fb95a4268112583bb0ae740873353450aa6c412c
Author: Jonas Danielsson <jonas danielsson threetimestwo org>
Date: Fri Oct 17 05:41:23 2014 -0400
location: Unescape geo uri description
Use g_uri_unescape on the description for geo uri formats
such as:
geo:0,0?q=lat,lon(description)
This will allow us to have space in the description by
using %20.
Example:
geo:0,0?q=lat,lon(My%20Location)
The above will give a description of "My Location".
https://bugzilla.gnome.org/show_bug.cgi?id=737979
geocode-glib/geocode-location.c | 4 +++-
geocode-glib/test-geouri.c | 15 +++++++++++++++
2 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/geocode-glib/geocode-location.c b/geocode-glib/geocode-location.c
index e592c5a..c5bbe98 100644
--- a/geocode-glib/geocode-location.c
+++ b/geocode-glib/geocode-location.c
@@ -241,7 +241,9 @@ parse_geo_uri_special_parameters (GeocodeLocation *loc,
if (description_len <= 0)
goto err;
- description = g_strndup (next_token, description_len);
+ description = g_uri_unescape_segment (next_token,
+ next_token + description_len,
+ NULL);
geocode_location_set_description (loc, description);
g_free (description);
return TRUE;
diff --git a/geocode-glib/test-geouri.c b/geocode-glib/test-geouri.c
index 59b4b2e..0bbcd78 100644
--- a/geocode-glib/test-geouri.c
+++ b/geocode-glib/test-geouri.c
@@ -99,6 +99,20 @@ test_valid_uri (void)
}
static void
+test_unescape_uri (void)
+{
+ GeocodeLocation *loc;
+ char *uri = "geo:0,0?q=57.038,12.3982(Parkvägen%202,%20Tvååker)";
+
+ loc = geocode_location_new (0, 0, 0);
+ g_assert (geocode_location_set_from_uri (loc, uri, NULL));
+ g_assert_cmpstr (geocode_location_get_description(loc),
+ ==,
+ "Parkvägen 2, Tvååker");
+ g_object_unref (loc);
+}
+
+static void
test_convert_from_to_location (void)
{
GeocodeLocation *loc;
@@ -156,6 +170,7 @@ int main (int argc, char **argv)
g_test_add_func ("/geouri/parse_uri", test_parse_uri);
g_test_add_func ("/geouri/valid_uri", test_valid_uri);
+ g_test_add_func ("/geouri/unescape_uri", test_unescape_uri);
g_test_add_func ("/geouri/convert_uri", test_convert_from_to_location);
return g_test_run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]