[PATCH spice-gtk 3/4] spice-uri: Set user & password to NULL when not specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avoid using old values after parsing a new uri.

Related: rhbz#1335239
---
 src/spice-uri.c        | 3 +++
 tests/test-spice-uri.c | 8 ++++++++
 2 files changed, 11 insertions(+)

diff --git a/src/spice-uri.c b/src/spice-uri.c
index 0cc2195..35d773e 100644
--- a/src/spice-uri.c
+++ b/src/spice-uri.c
@@ -141,6 +141,9 @@ gboolean spice_uri_parse(SpiceURI *self, const gchar *_uri, GError **error)
         spice_uri_set_user(self, user);
         spice_uri_set_password(self, pass);
         uri = next;
+    } else {
+        spice_uri_set_user(self, NULL);
+        spice_uri_set_password(self, NULL);
     }
 
     /* max 2 parts, host:port */
diff --git a/tests/test-spice-uri.c b/tests/test-spice-uri.c
index 993cc78..d556e01 100644
--- a/tests/test-spice-uri.c
+++ b/tests/test-spice-uri.c
@@ -51,6 +51,14 @@ static void test_spice_uri_ipv4(void)
     g_assert_cmpstr(spice_uri_get_password(uri), ==, "password");
     g_assert_cmpuint(spice_uri_get_port(uri), ==, 80);
 
+    /* new parsing resets values */
+    g_assert_true(spice_uri_parse(uri, "http://127.0.0.1";, NULL));
+    g_assert_cmpstr(spice_uri_get_scheme(uri), ==, "http");
+    g_assert_cmpstr(spice_uri_get_hostname(uri), ==, "127.0.0.1");
+    g_assert_cmpstr(spice_uri_get_user(uri), ==, NULL);
+    g_assert_cmpstr(spice_uri_get_password(uri), ==, NULL);
+    g_assert_cmpuint(spice_uri_get_port(uri), ==, 3128);
+
     g_object_unref(uri);
 }
 
-- 
2.8.2

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]