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 4DCE9E306 for ; Mon, 11 Feb 2013 20:03:28 +0000 (UTC) Received: (qmail 10809 invoked by uid 500); 11 Feb 2013 20:03:28 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 10770 invoked by uid 500); 11 Feb 2013 20:03:28 -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 10762 invoked by uid 99); 11 Feb 2013 20:03:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 20:03:28 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Feb 2013 20:03:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 622FC238890B for ; Mon, 11 Feb 2013 20:03:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1444942 - /httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java Date: Mon, 11 Feb 2013 20:03:08 -0000 To: commits@hc.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130211200308.622FC238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sebb Date: Mon Feb 11 20:03:08 2013 New Revision: 1444942 URL: http://svn.apache.org/r1444942 Log: Make repeat string in IPv4 expression more obvious Remove non-capturing groups for clarity Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java?rev=1444942&r1=1444941&r2=1444942&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java (original) +++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/conn/util/InetAddressUtils.java Mon Feb 11 20:03:08 2013 @@ -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}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; + "(([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 . + "([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 = Pattern.compile("^" + IPV4_BASIC_PATTERN_STRING + "$"); @@ -53,11 +54,11 @@ public class InetAddressUtils { private static final Pattern IPV6_STD_PATTERN = Pattern.compile( - "^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$"); + "^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$"); private static final Pattern IPV6_HEX_COMPRESSED_PATTERN = Pattern.compile( - "^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$"); + "^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4})*)?)$"); public static boolean isIPv4Address(final String input) { return IPV4_PATTERN.matcher(input).matches();