Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 75747 invoked from network); 16 Aug 2004 01:11:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 16 Aug 2004 01:11:35 -0000 Received: (qmail 37673 invoked by uid 500); 16 Aug 2004 01:11:32 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 37622 invoked by uid 500); 16 Aug 2004 01:11:32 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 37606 invoked by uid 99); 16 Aug 2004 01:11:32 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received: from [64.233.170.193] (HELO mproxy.gmail.com) (64.233.170.193) by apache.org (qpsmtpd/0.27.1) with ESMTP; Sun, 15 Aug 2004 18:11:31 -0700 Received: by mproxy.gmail.com with SMTP id v18so60770rnb for ; Sun, 15 Aug 2004 18:11:30 -0700 (PDT) Received: by 10.38.206.50 with SMTP id d50mr1111857rng; Sun, 15 Aug 2004 18:11:30 -0700 (PDT) Message-ID: <16d6c620040815181159718cef@mail.gmail.com> Date: Sun, 15 Aug 2004 18:11:30 -0700 From: Martin Cooper Reply-To: Martin Cooper To: Jakarta Commons Developers List Subject: Re: [validator] UrlValidator In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N On Sun, 15 Aug 2004 17:34:01 -0400, Tim Reilly wrote: > I'd posted this to commons-user back in July, never got an answer and went > on with my reqs using a regex instead. > I saw Martin's post today on a 1.1.3 release and figured I should I forward > this to see if it was a bug or only that fully 'resolved' urls are valid or > something and I was using incorrectly? This looks like a bug to me. Interestingly, the test code treats an empty path in a URL as invalid, whereas RFC 2396 allows it. This is obviously part of the problem. If you could file a bug for this in Bugzilla, that will make sure it doesn't get lost. Most likely, a fix will show up in 1.1.4. By the way, your comments below suggest that you're passing the entire URL to isValidScheme() et al. You should note that these methods take only the part of the URL corresponding to their name, not the entire URL. In other words, calling isValidScheme("http://www.google.com") *should* fail, whereas isValidScheme("http") will succeed. -- Martin Cooper > > > -----Original Message----- > > From: Tim Reilly > > Sent: Wednesday, July 28, 2004 11:53 AM > > To: commons-user@jakarta.apache.org > > Subject: [validator] UrlValidator > > > > > > First, I'm a newbie with validator, so maybe I'm just not using > > it correctly. > > I was hoping to use validator library to validate url strings > > from a form. I'm finding the validation too strict for my use > > case. I have a form and want to validate the the user entered a > > valid url in 'simple user' terms of valid. > > > > But...I added this test case/method to > > org.apache.commons.validator.UrlTest; the url is valid from my POV. > > > > public void testSanity() { > > UrlValidator v = new UrlValidator(); > > assertTrue(v.isValid("http://www.google.com")); > > } > > > > But it fails. > > > > Also testing http://www.google.com with: > > isValidScheme : false > > isValidAuthority : false > > isValidPath : false > > isValidQuery : true > > isValidFragment: true > > > > Can anyone explain the UrlValidator.isValidXXXXX ? > > Why would query and fragment be valid (I guess because they > > aren't specified. I'm good with that.) > > But can't port and path be optional not specified as well? > > Also why is the scheme (http://) not valid? > > > > Oddly, the url http://www.google.com:80/test passes isValid(), > > but fails isValidScheme(), etc.. > > > > Thanks, > > -TR > > > > (btw: Testing against HEAD / 1.1.3) > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org