aboutsummaryrefslogtreecommitdiff
path: root/dbfp_check.c
diff options
context:
space:
mode:
authorRobin Krahl <me@robin-krahl.de>2016-03-10 17:48:52 +0100
committerRobin Krahl <me@robin-krahl.de>2016-03-10 17:48:52 +0100
commit2d3fffa502e808452848b7396b4e121917ddc787 (patch)
treebf1454029d010ed8d08c0788c239828b28a54e7a /dbfp_check.c
parent4c68c15d4d3102b26b824b0021901d1dd9d79e77 (diff)
downloaddbfp-2d3fffa502e808452848b7396b4e121917ddc787.tar.gz
dbfp-2d3fffa502e808452848b7396b4e121917ddc787.tar.bz2
dbfp: URL-encode the input for the location query
In dbfp_query_location_name, URL-encode the input string using curl before sending the HTTP request. This fixes the issue that input strings with non-URL characters leed to empty results.
Diffstat (limited to 'dbfp_check.c')
-rw-r--r--dbfp_check.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/dbfp_check.c b/dbfp_check.c
index a9da26c..29db4a3 100644
--- a/dbfp_check.c
+++ b/dbfp_check.c
@@ -89,6 +89,24 @@ START_TEST(test_dbfp_location_simple)
free(locations);
locations = NULL;
+ err = dbfp_query_location_name(&dbfp, "freiburg im", &n, &locations);
+ ck_assert_int_eq(err, 0);
+
+ ck_assert_int_gt(n, 0);
+ ck_assert_ptr_ne(locations, NULL);
+
+ ck_assert_str_eq(locations[0].name, "Freiburg(Breisgau) Hbf");
+ ck_assert_str_eq(locations[0].id, "008000107");
+ ck_assert(locations[0].lon == 7.841173f);
+ ck_assert(locations[0].lat == 47.997696f);
+
+ for (i = 0; i < n; i++) {
+ free(locations[i].name);
+ free(locations[i].id);
+ }
+ free(locations);
+ locations = NULL;
+
dbfp_close(&dbfp);
}
END_TEST