diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-10-06 19:31:32 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-10-06 19:34:47 (EDT) |
commit | 142ce1242222dfe39f189008b9ef6e79d2e82940 (patch) | |
tree | 48a54b1da87eae2965822a48edffd864ae7a1b71 /src | |
parent | 25125da0242cf3a55999f3101418a572a5e97c5f (diff) | |
download | marquee-142ce1242222dfe39f189008b9ef6e79d2e82940.zip marquee-142ce1242222dfe39f189008b9ef6e79d2e82940.tar.gz marquee-142ce1242222dfe39f189008b9ef6e79d2e82940.tar.bz2 |
src/about.c: URI-unescape query keys and values
Also, free query hash table (which now also frees duplicated key and
value strings).
Diffstat (limited to 'src')
-rw-r--r-- | src/about.c | 19 |
1 files changed, 14 insertions, 5 deletions
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 |