[epiphany] ephy-uri-helpers: Handle keys without a value
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] ephy-uri-helpers: Handle keys without a value
- Date: Thu, 22 May 2014 09:21:55 +0000 (UTC)
commit 63bd650009e14e255a74eb1bea1c0cd54ab535d8
Author: Bastien Nocera <hadess hadess net>
Date: Wed May 21 21:56:57 2014 +0200
ephy-uri-helpers: Handle keys without a value
Fixes a crash with a URI such as:
http://www.test.com/?some&valid&query
https://bugzilla.gnome.org/show_bug.cgi?id=730464
lib/ephy-uri-helpers.c | 15 ++++++++++-----
tests/ephy-uri-helpers-test.c | 3 +++
2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/lib/ephy-uri-helpers.c b/lib/ephy-uri-helpers.c
index 9212de1..aa8c2d2 100644
--- a/lib/ephy-uri-helpers.c
+++ b/lib/ephy-uri-helpers.c
@@ -90,12 +90,14 @@ query_split (const char *query)
pair = pairs[i];
eq = strchr (pair, '=');
- if (eq) {
+ if (eq)
decoded_name = g_strndup (pair, eq - pair);
- if (!form_decode (decoded_name)) {
- g_free (decoded_name);
- decoded_name = NULL;
- }
+ else
+ decoded_name = g_strdup (pair);
+
+ if (!form_decode (decoded_name)) {
+ g_free (decoded_name);
+ decoded_name = NULL;
}
item = g_slice_new0 (QueryItem);
@@ -170,6 +172,9 @@ is_garbage (const char *name,
};
guint i;
+ if (name == NULL)
+ return FALSE;
+
for (i = 0; i < G_N_ELEMENTS (fields); i++) {
if (fields[i].host != NULL &&
!g_str_has_suffix (host, fields[i].host))
diff --git a/tests/ephy-uri-helpers-test.c b/tests/ephy-uri-helpers-test.c
index 1d9fc8d..0052671 100644
--- a/tests/ephy-uri-helpers-test.c
+++ b/tests/ephy-uri-helpers-test.c
@@ -51,6 +51,9 @@ test_ephy_uri_helpers_remove_tracking (void)
{
"https://mail.google.com/mail/u/0/?ui=2&ik=37373eb942&rid=7cea..&auto=1&view=lno&_reqid=1168127&pcd=1&mb=0&rt=j";,
"https://mail.google.com/mail/u/0/?ui=2&ik=37373eb942&rid=7cea..&auto=1&view=lno&_reqid=1168127&pcd=1&mb=0&rt=j";
},
{ "http://www.test.com/?utm_source=feedburner&view=lno&_reqid=1234";,
"http://www.test.com/?view=lno&_reqid=1234"; },
+ { "http://www.test.com/?some&valid&query";, "http://www.test.com/?some&valid&query"; },
+ { "http://www.test.com/?utm_source=feedburner&some&valid&query";, "http://www.test.com/?some&valid&query";
},
+
};
guint i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]