[Xfce4-commits] <midori:master> Validate IP address in proxy server preference
Christian Dywan
noreply at xfce.org
Wed Aug 29 01:10:05 CEST 2012
Updating branch refs/heads/master
to 0f1f26480dda3168173d87f581e4992d97dc0a96 (commit)
from 36c3a4925a1d58c91e76da863b654f8d45d769cd (commit)
commit 0f1f26480dda3168173d87f581e4992d97dc0a96
Author: Christian Dywan <christian at twotoasts.de>
Date: Tue Aug 28 23:57:57 2012 +0200
Validate IP address in proxy server preference
Fixes: https://bugs.launchpad.net/midori/+bug/783044
katze/katze-utils.c | 2 ++
katze/midori-uri.vala | 3 +++
midori/midori-preferences.c | 2 +-
tests/magic-uri.c | 14 ++++++++++++++
4 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/katze/katze-utils.c b/katze/katze-utils.c
index 1433f43..b082c3e 100644
--- a/katze/katze-utils.c
+++ b/katze/katze-utils.c
@@ -1531,6 +1531,8 @@ katze_uri_entry_changed_cb (GtkWidget* entry,
gboolean valid = midori_uri_is_location (uri);
if (!valid && g_object_get_data (G_OBJECT (entry), "allow_%s"))
valid = uri && g_str_has_prefix (uri, "%s");
+ if (!valid)
+ valid = midori_uri_is_ip_address (uri);
#if GTK_CHECK_VERSION (3, 2, 0)
g_object_set_data (G_OBJECT (entry), "invalid", GINT_TO_POINTER (*uri && !valid));
diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala
index c823a48..5a8fab3 100644
--- a/katze/midori-uri.vala
+++ b/katze/midori-uri.vala
@@ -127,6 +127,9 @@ namespace Midori {
we'd have to separate the path from the URI first. */
if (uri == null)
return false;
+ /* Skip leading user/ password */
+ if (uri.chr (-1, '@') != null)
+ return is_ip_address (uri.split ("@")[1]);
/* IPv4 */
if (uri[0].isdigit () && (uri.chr (4, '.') != null))
return true;
diff --git a/midori/midori-preferences.c b/midori/midori-preferences.c
index f685c58..f00a799 100644
--- a/midori/midori-preferences.c
+++ b/midori/midori-preferences.c
@@ -466,7 +466,7 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
label = gtk_label_new (_("Hostname"));
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
INDENTED_ADD (label);
- entry = katze_property_proxy (settings, "http-proxy", NULL);
+ entry = katze_property_proxy (settings, "http-proxy", "address");
SPANNED_ADD (entry);
g_signal_connect (settings, "notify::proxy-type",
G_CALLBACK (midori_preferences_notify_proxy_type_cb), entry);
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
index 53bee47..826307f 100644
--- a/tests/magic-uri.c
+++ b/tests/magic-uri.c
@@ -254,6 +254,19 @@ magic_uri_fingerprint (void)
}
static void
+magic_uri_ip (void)
+{
+ g_assert (midori_uri_is_ip_address ("192.168.1.1"));
+ g_assert (midori_uri_is_ip_address ("192.168.1.1:1234"));
+ g_assert (midori_uri_is_ip_address ("user at 192.168.1.1"));
+ g_assert (midori_uri_is_ip_address ("user:password at 192.168.1.1"));
+ g_assert (midori_uri_is_ip_address ("2001:0db8:85a3:0000:0000:8a2e:0370:7334"));
+ g_assert (midori_uri_is_ip_address ("fe80:0:0:0:202:b3ff:fe1e:8329"));
+ g_assert (midori_uri_is_ip_address ("fe80::202:b3ff:fe1e:8329"));
+ g_assert (midori_uri_is_ip_address ("fe80::76e5:bff:fe04:38e0/64"));
+}
+
+static void
magic_uri_format (void)
{
typedef struct
@@ -357,6 +370,7 @@ main (int argc,
g_test_add_func ("/magic-uri/pseudo", magic_uri_pseudo);
g_test_add_func ("/magic-uri/performance", magic_uri_performance);
g_test_add_func ("/magic-uri/fingerprint", magic_uri_fingerprint);
+ g_test_add_func ("/magic-uri/ip", magic_uri_ip);
g_test_add_func ("/magic-uri/format", magic_uri_format);
g_test_add_func ("/magic-uri/prefetch", magic_uri_prefetch);
g_test_add_func ("/magic-uri/commands", magic_uri_commands);
More information about the Xfce4-commits
mailing list