[network-manager-applet/th/rh962449_link_local_dns_server: 2/3] editor: disallow unexpected characters for DNS servers
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/th/rh962449_link_local_dns_server: 2/3] editor: disallow unexpected characters for DNS servers
- Date: Fri, 4 Oct 2013 16:19:57 +0000 (UTC)
commit 264b6f295991fdf73f3d0f5c120febb0f33708ea
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 | 24 ++++++++++++++++++++++++
src/connection-editor/page-ip6.c | 23 +++++++++++++++++++++++
2 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index e4371ec..fccc9cf 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -635,6 +635,29 @@ ip_address_filter_cb (GtkEditable *editable,
}
}
+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 *editable,
+ gchar *text,
+ gint length,
+ gint *position,
+ gpointer user_data)
+{
+ utils_filter_editable_on_insert_text (editable,
+ text, length, position, user_data,
+ _char_is_ascii_dns_servers,
+ dns_servers_filter_cb);
+}
+
static void
delete_text_cb (GtkEditable *editable,
gint start_pos,
@@ -950,6 +973,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 306d765..b7ee693 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -615,6 +615,28 @@ ip_address_filter_cb (GtkEditable *editable,
}
}
+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 *editable,
+ gchar *text,
+ gint length,
+ gint *position,
+ gpointer user_data)
+{
+ utils_filter_editable_on_insert_text (editable,
+ text, length, position, user_data,
+ _char_is_ascii_dns_servers,
+ dns_servers_filter_cb);
+}
+
static void
delete_text_cb (GtkEditable *editable,
gint start_pos,
@@ -914,6 +936,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]