[geocode-glib/wip/issue-18] location: Allow unknown parameters inside geo: URL
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geocode-glib/wip/issue-18] location: Allow unknown parameters inside geo: URL
- Date: Wed, 6 Nov 2019 15:57:22 +0000 (UTC)
commit 5f31b1c70e0609cd5313d5bad5873048e5cecfe9
Author: Thomas Pointhuber <thomas pointhuber gmx at>
Date: Mon Aug 29 21:41:03 2016 +0200
location: Allow unknown parameters inside geo: URL
geocode-glib/geocode-location.c | 40 ++++++++++++++++++----------------------
geocode-glib/tests/geo-uri.c | 3 +++
2 files changed, 21 insertions(+), 22 deletions(-)
---
diff --git a/geocode-glib/geocode-location.c b/geocode-glib/geocode-location.c
index debe27b..70a94c1 100644
--- a/geocode-glib/geocode-location.c
+++ b/geocode-glib/geocode-location.c
@@ -337,42 +337,38 @@ parse_geo_uri_parameters (GeocodeLocation *loc,
char *val;
char *u = NULL;
char *crs = NULL;
+ int i;
int ret = TRUE;
- parameters = g_strsplit (params, ";", 2);
+ parameters = g_strsplit (params, ";", 256);
if (parameters[0] == NULL)
goto err;
- if (g_str_has_prefix (parameters[0], "u=")) {
- /*
- * if u parameter is first, then there should not be any more
- * parameters.
- */
- if (parameters[1] != NULL)
- goto err;
-
- u = parameters[0];
- } else if (g_str_has_prefix (parameters[0], "crs=")) {
- /*
- * if crs parameter is first, then the next should be the u
- * parameter or none.
- */
- crs = parameters[0];
- if (parameters[1] != NULL){
+ for (i = 0; parameters[i] != NULL; i++) {
+ if (g_str_has_prefix (parameters[i], "crs=")) {
+ /*
+ * if crs parameter is given, it has to be the first one
+ */
+ if (i != 0)
+ goto err;
- if (!g_str_has_prefix (parameters[1], "u="))
+ crs = parameters[i];
+ } else if (g_str_has_prefix (parameters[i], "u=")) {
+ /*
+ * u parameter is either first one or after crs parameter and
+ * has to appear only once in the parameter list
+ */
+ if ((crs == NULL && i != 0) || (crs != NULL && i != 1) || u != NULL)
goto err;
- u = parameters[1];
+ u = parameters[i];
}
- } else {
- goto err;
}
if (u != NULL) {
val = u + 2; /* len of 'u=' */
loc->priv->accuracy = g_ascii_strtod (val, &endptr);
- if (*endptr != '\0')
+ if (*endptr != '\0' && *endptr != ';')
goto err;
}
diff --git a/geocode-glib/tests/geo-uri.c b/geocode-glib/tests/geo-uri.c
index 4bd50de..082e1ab 100644
--- a/geocode-glib/tests/geo-uri.c
+++ b/geocode-glib/tests/geo-uri.c
@@ -42,6 +42,9 @@ static struct uri uris[] = {
{ "geo:13.37,42.42;u=45.5", TRUE },
{ "geo:13.37,42.42,12.12;u=45.5", TRUE },
{ "geo:13.37,42.42,12.12;crs=wgs84;u=45.5", TRUE },
+ { "geo:13.37,42.42,12.12;crs=wgs84;u=45.5;u=10", FALSE },
+ { "geo:13.37,42.42,12.12;crs=wgs84;u=45.5;crs=wgs84", FALSE },
+ { "geo:13.37,42.42,12.12;crs=wgs84;u=45.5;z=18", TRUE },
{ "geo:0.0,0,0", TRUE },
{ "geo :0.0,0,0", FALSE },
{ "geo:0.0 ,0,0", FALSE },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]