From 142ce1242222dfe39f189008b9ef6e79d2e82940 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Fri, 06 Oct 2017 19:31:32 -0400 Subject: src/about.c: URI-unescape query keys and values Also, free query hash table (which now also frees duplicated key and value strings). --- (limited to 'src/about.c') diff --git a/src/about.c b/src/about.c index 47d0c5b..39e6a7a 100644 --- a/src/about.c +++ b/src/about.c @@ -34,24 +34,30 @@ parse_query_string(gchar *str) gchar *key; gchar *val; - hash_table = g_hash_table_new(g_str_hash, g_str_equal); + hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, + g_free, g_free); while (*str) { key = str; for (; *str && *str != '='; ++str); if (!*str) { - g_hash_table_insert(hash_table, key, NULL); + g_hash_table_insert(hash_table, + g_uri_unescape_string(key, NULL), NULL); break; } *str = '\0'; val = ++str; for (; *str && *str != '&'; ++str); if (!*str) { - g_hash_table_insert(hash_table, key, val); + g_hash_table_insert(hash_table, + g_uri_unescape_string(key, NULL), + g_uri_unescape_string(val, NULL)); break; } *str = '\0'; - g_hash_table_insert(hash_table, key, val); + g_hash_table_insert(hash_table, + g_uri_unescape_string(key, NULL), + g_uri_unescape_string(val, NULL)); ++str; } @@ -70,6 +76,7 @@ mq_about_request(WebKitURISchemeRequest *request, MqApplication *application) if (query_str && query_str[1]) { query_str = g_strdup(query_str + 1); query = parse_query_string(query_str); + g_free(query_str); } else { query = NULL; } @@ -84,7 +91,9 @@ mq_about_request(WebKitURISchemeRequest *request, MqApplication *application) return; } - g_free(query_str); + if (query) { + g_hash_table_unref(query); + } } void -- cgit v0.9.1