Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 433DC17869 for ; Wed, 11 Mar 2015 20:20:05 +0000 (UTC) Received: (qmail 36896 invoked by uid 500); 11 Mar 2015 20:20:05 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 36855 invoked by uid 500); 11 Mar 2015 20:20:05 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 36844 invoked by uid 99); 11 Mar 2015 20:20:05 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Mar 2015 20:20:05 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 028B9AC026D for ; Wed, 11 Mar 2015 20:20:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1665991 - in /httpcomponents/httpclient/branches/4.4.x/httpclient/src: main/java/org/apache/http/conn/util/InetAddressUtils.java test/java/org/apache/http/conn/util/TestInetAddressUtils.java Date: Wed, 11 Mar 2015 20:20:04 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150311202005.028B9AC026D@hades.apache.org> Author: olegk Date: Wed Mar 11 20:20:04 2015 New Revision: 1665991 URL: http://svn.apache.org/r1665991 Log: HTTPCLIENT-1631: IPv4 addresses parser accepts addresses that starts with zero Contributed by Maxim Kirilov Modified: httpcomponents/httpclient/branches/4.4.x/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java httpcomponents/httpclient/branches/4.4.x/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java Modified: httpcomponents/httpclient/branches/4.4.x/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.4.x/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java?rev=1665991&r1=1665990&r2=1665991&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.4.x/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java (original) +++ httpcomponents/httpclient/branches/4.4.x/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java Wed Mar 11 20:20:04 2015 @@ -43,7 +43,8 @@ public class InetAddressUtils { } private static final String IPV4_BASIC_PATTERN_STRING = - "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" + // initial 3 fields, 0-255 followed by . + "(([1-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){1}" + // initial first field, 1-255 + "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){2}" + // following 2 fields, 0-255 followed by . "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; // final field, 0-255 private static final Pattern IPV4_PATTERN = Modified: httpcomponents/httpclient/branches/4.4.x/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.4.x/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java?rev=1665991&r1=1665990&r2=1665991&view=diff ============================================================================== --- httpcomponents/httpclient/branches/4.4.x/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java (original) +++ httpcomponents/httpclient/branches/4.4.x/httpclient/src/test/java/org/apache/http/conn/util/TestInetAddressUtils.java Wed Mar 11 20:20:04 2015 @@ -48,6 +48,7 @@ public class TestInetAddressUtils { Assert.assertFalse(InetAddressUtils.isIPv4Address("g.ar.ba.ge")); Assert.assertFalse(InetAddressUtils.isIPv4Address("192.168.0")); Assert.assertFalse(InetAddressUtils.isIPv4Address("256.255.255.255")); + Assert.assertFalse(InetAddressUtils.isIPv4Address("0.168.0.0")); //IP address that starts with zero not allowed } @Test