Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0C4971873C for ; Mon, 9 Nov 2015 23:39:23 +0000 (UTC) Received: (qmail 39951 invoked by uid 500); 9 Nov 2015 23:39:22 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 39865 invoked by uid 500); 9 Nov 2015 23:39:22 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 39856 invoked by uid 99); 9 Nov 2015 23:39:22 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Nov 2015 23:39:22 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 284B31A0A24 for ; Mon, 9 Nov 2015 23:39:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.791 X-Spam-Level: * X-Spam-Status: No, score=1.791 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01, WEIRD_PORT=0.001] autolearn=disabled Received: from mx1-us-east.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id OOYp4Aotj-98 for ; Mon, 9 Nov 2015 23:39:20 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-east.apache.org (ASF Mail Server at mx1-us-east.apache.org) with ESMTP id D0F0C441AB for ; Mon, 9 Nov 2015 23:39:19 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 36D6AE0253 for ; Mon, 9 Nov 2015 23:39:19 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 0F9853A05DF for ; Mon, 9 Nov 2015 23:39:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1713569 - in /commons/proper/validator/trunk/src: changes/changes.xml main/java/org/apache/commons/validator/routines/UrlValidator.java test/java/org/apache/commons/validator/routines/UrlValidatorTest.java Date: Mon, 09 Nov 2015 23:39:18 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151109233919.0F9853A05DF@svn01-us-west.apache.org> Author: sebb Date: Mon Nov 9 23:39:18 2015 New Revision: 1713569 URL: http://svn.apache.org/viewvc?rev=1713569&view=rev Log: VALIDATOR-380 UrlValidator does not allow for optional port digits Modified: commons/proper/validator/trunk/src/changes/changes.xml commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java Modified: commons/proper/validator/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/changes/changes.xml?rev=1713569&r1=1713568&r2=1713569&view=diff ============================================================================== --- commons/proper/validator/trunk/src/changes/changes.xml (original) +++ commons/proper/validator/trunk/src/changes/changes.xml Mon Nov 9 23:39:18 2015 @@ -90,6 +90,9 @@ The dependencies for Validator have not For the current list of dependencies, please see http://commons.apache.org/validator/dependencies.html "> + + UrlValidator does not allow for optional port digits + IIBANCheckDigit.calculate does not enforce initial checksum value Checkdigit field is now unconditionally set to "00" to ensure correct generation Modified: commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java?rev=1713569&r1=1713568&r2=1713569&view=diff ============================================================================== --- commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java (original) +++ commons/proper/validator/trunk/src/main/java/org/apache/commons/validator/routines/UrlValidator.java Mon Nov 9 23:39:18 2015 @@ -146,15 +146,16 @@ public class UrlValidator implements Ser USERINFO_CHARS_REGEX + "+:" + // At least one character for the name USERINFO_CHARS_REGEX + "*@"; // password may be absent private static final String AUTHORITY_REGEX = - "^(?:\\[("+IPV6_REGEX+")\\]|(?:(?:"+USERINFO_FIELD_REGEX+")?([" + AUTHORITY_CHARS_REGEX + "]*)))(:\\d*)?(.*)?"; - // 1 e.g. user:pass@ 2 3 4 + "(?:\\[("+IPV6_REGEX+")\\]|(?:(?:"+USERINFO_FIELD_REGEX+")?([" + AUTHORITY_CHARS_REGEX + "]*)))(:\\d*)?(.*)?"; + // 1 e.g. user:pass@ 2 3 4 private static final Pattern AUTHORITY_PATTERN = Pattern.compile(AUTHORITY_REGEX); private static final int PARSE_AUTHORITY_IPV6 = 1; - private static final int PARSE_AUTHORITY_HOST_IP = 2; + private static final int PARSE_AUTHORITY_HOST_IP = 2; // excludes userinfo, if present - private static final int PARSE_AUTHORITY_PORT = 3; + // Not needed, because it is validated by AUTHORITY_REGEX +// private static final int PARSE_AUTHORITY_PORT = 3; /** * Should always be empty. The code currently allows spaces. @@ -167,9 +168,6 @@ public class UrlValidator implements Ser private static final String QUERY_REGEX = "^(.*)$"; private static final Pattern QUERY_PATTERN = Pattern.compile(QUERY_REGEX); - private static final String PORT_REGEX = "^:(\\d{1,5})$"; - private static final Pattern PORT_PATTERN = Pattern.compile(PORT_REGEX); - /** * Holds the set of current validation options. */ @@ -311,9 +309,14 @@ public class UrlValidator implements Ser } String authority = urlMatcher.group(PARSE_URL_AUTHORITY); - if ("file".equals(scheme) && "".equals(authority)) { - // Special case - file: allows an empty authority - } else { + if ("file".equals(scheme)) {// Special case - file: allows an empty authority + if (!"".equals(authority)) { + if (authority.contains(":")) { // but cannot allow trailing : + return false; + } + } + // drop through to continue validation + } else { // not file: // Validate the authority if (!isValidAuthority(authority)) { return false; @@ -410,11 +413,6 @@ public class UrlValidator implements Ser } } - String port = authorityMatcher.group(PARSE_AUTHORITY_PORT); - if (port != null && !PORT_PATTERN.matcher(port).matches()) { - return false; - } - String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA); if (extra != null && extra.trim().length() > 0){ return false; Modified: commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java URL: http://svn.apache.org/viewvc/commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java?rev=1713569&r1=1713568&r2=1713569&view=diff ============================================================================== --- commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java (original) +++ commons/proper/validator/trunk/src/test/java/org/apache/commons/validator/routines/UrlValidatorTest.java Mon Nov 9 23:39:18 2015 @@ -441,8 +441,7 @@ public class UrlValidatorTest extends Te UrlValidator validator = new UrlValidator(); assertTrue(validator.isValid("http://www.apache.org:80/path")); assertTrue(validator.isValid("http://www.apache.org:8/path")); - // To be enabled when code has been fixed -// assertTrue(validator.isValid("http://www.apache.org:/path")); + assertTrue(validator.isValid("http://www.apache.org:/path")); } /**