[network-manager-applet/th/rh962449_link_local_dns_server: 3/4] editor: disallow unexpected characters for DNS servers



commit e11a4401c0cc5d773d4d05d370996a470f0cd1f5
Author: Thomas Haller <thaller redhat com>
Date:   Fri Sep 27 23:46:58 2013 +0200

    editor: disallow unexpected characters for DNS servers
    
    Do not allow to input unexpected (ascii) characters as DNS servers,
    both for IPv4 and IPv6.
    
    This especially disallows to add a %scope-id suffix for IPv6 link-local
    addresses (because '%' is not allowed). The reason to disallow this is
    that link-local addresses are always scoped to the connecting device
    anyway, so this parameter would get ignored anyway.
    
    This is related to bug
    https://bugzilla.redhat.com/show_bug.cgi?id=962449
    
    Signed-off-by: Thomas Haller <thaller redhat com>

 src/connection-editor/page-ip4.c |   25 +++++++++++++++++++++++++
 src/connection-editor/page-ip6.c |   24 ++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
---
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 0d3f2b5..a9d04d9 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -638,6 +638,30 @@ ip_address_filter_cb (GtkEditable *entry,
                g_free (result);
 }
 
+static gboolean
+_char_is_ascii_dns_servers (char character)
+{
+       return utils_char_is_ascii_ip4_address (character) ||
+              character == ' ' ||
+              character == ',' ||
+              character == ':' ||
+              character == ';';
+}
+
+static void
+dns_servers_filter_cb (GtkEditable *entry,
+                       gchar *text,
+                       gint length,
+                       gint *position,
+                       gpointer user_data)
+{
+       utils_filter_editable_on_insert_text (GTK_EDITABLE (entry),
+                                             text, length, position, user_data,
+                                             _char_is_ascii_dns_servers,
+                                             dns_servers_filter_cb,
+                                             NULL, NULL);
+}
+
 static void
 delete_text_cb (GtkEditable *editable,
                     gint start_pos,
@@ -953,6 +977,7 @@ finish_setup (CEPageIP4 *self, gpointer unused, GError *error, gpointer user_dat
        g_signal_connect (selection, "changed", G_CALLBACK (list_selection_changed), priv->addr_delete);
 
        g_signal_connect_swapped (priv->dns_servers, "changed", G_CALLBACK (ce_page_changed), self);
+       g_signal_connect (priv->dns_servers, "insert-text", G_CALLBACK (dns_servers_filter_cb), self);
        g_signal_connect_swapped (priv->dns_searches, "changed", G_CALLBACK (ce_page_changed), self);
 
        method_changed (priv->method, self);
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 9b1a11b..d513ec9 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -618,6 +618,29 @@ ip_address_filter_cb (GtkEditable *entry,
                g_free (result);
 }
 
+static gboolean
+_char_is_ascii_dns_servers (char character)
+{
+       return utils_char_is_ascii_ip6_address (character) ||
+              character == ' ' ||
+              character == ',' ||
+              character == ';';
+}
+
+static void
+dns_servers_filter_cb (GtkEditable *entry,
+                       gchar *text,
+                       gint length,
+                       gint *position,
+                       gpointer user_data)
+{
+       utils_filter_editable_on_insert_text (GTK_EDITABLE (entry),
+                                             text, length, position, user_data,
+                                             _char_is_ascii_dns_servers,
+                                             dns_servers_filter_cb,
+                                             NULL, NULL);
+}
+
 static void
 delete_text_cb (GtkEditable *editable,
                     gint start_pos,
@@ -917,6 +940,7 @@ finish_setup (CEPageIP6 *self, gpointer unused, GError *error, gpointer user_dat
        g_signal_connect (selection, "changed", G_CALLBACK (list_selection_changed), priv->addr_delete);
 
        g_signal_connect_swapped (priv->dns_servers, "changed", G_CALLBACK (ce_page_changed), self);
+       g_signal_connect (priv->dns_servers, "insert-text", G_CALLBACK (dns_servers_filter_cb), self);
        g_signal_connect_swapped (priv->dns_searches, "changed", G_CALLBACK (ce_page_changed), self);
 
        method_changed (priv->method, self);


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