[Xfce4-commits] <midori:master> Check that valid IP address has no leading 0
Christian Dywan
noreply at xfce.org
Thu Aug 30 00:44:04 CEST 2012
Updating branch refs/heads/master
to 58d1436d4e37787c0d7107e8f542b9f061b39086 (commit)
from 1c1fd1740e4053ba7e5e5ee8b6d4832523c60299 (commit)
commit 58d1436d4e37787c0d7107e8f542b9f061b39086
Author: Christian Dywan <christian at twotoasts.de>
Date: Wed Aug 29 20:28:46 2012 +0200
Check that valid IP address has no leading 0
katze/midori-uri.vala | 2 +-
tests/magic-uri.c | 1 +
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/katze/midori-uri.vala b/katze/midori-uri.vala
index 5a8fab3..21681cb 100644
--- a/katze/midori-uri.vala
+++ b/katze/midori-uri.vala
@@ -131,7 +131,7 @@ namespace Midori {
if (uri.chr (-1, '@') != null)
return is_ip_address (uri.split ("@")[1]);
/* IPv4 */
- if (uri[0].isdigit () && (uri.chr (4, '.') != null))
+ if (uri[0] != '0' && uri[0].isdigit () && (uri.chr (4, '.') != null))
return true;
/* IPv6 */
if (uri[0].isalnum () && uri[1].isalnum ()
diff --git a/tests/magic-uri.c b/tests/magic-uri.c
index 826307f..d90e2b3 100644
--- a/tests/magic-uri.c
+++ b/tests/magic-uri.c
@@ -258,6 +258,7 @@ 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 ("0.168.1.1"));
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"));
More information about the Xfce4-commits
mailing list