Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 865DC7616 for ; Tue, 4 Oct 2011 22:13:22 +0000 (UTC) Received: (qmail 93590 invoked by uid 500); 4 Oct 2011 22:13:19 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 93526 invoked by uid 500); 4 Oct 2011 22:13:19 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 93517 invoked by uid 99); 4 Oct 2011 22:13:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 22:13:19 +0000 X-ASF-Spam-Status: No, hits=0.7 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [76.96.62.40] (HELO qmta04.westchester.pa.mail.comcast.net) (76.96.62.40) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 04 Oct 2011 22:13:11 +0000 Received: from omta17.westchester.pa.mail.comcast.net ([76.96.62.89]) by qmta04.westchester.pa.mail.comcast.net with comcast id glsb1h0071vXlb854mCrKr; Tue, 04 Oct 2011 22:12:51 +0000 Received: from [192.168.1.201] ([69.143.109.145]) by omta17.westchester.pa.mail.comcast.net with comcast id gmCq1h00K38FjT13dmCqeR; Tue, 04 Oct 2011 22:12:51 +0000 Message-ID: <4E8B84E4.8080708@christopherschultz.net> Date: Tue, 04 Oct 2011 18:12:52 -0400 From: Christopher Schultz User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: Tomcat Users List Subject: Re: Denying IPs using the Valve command in context.xml References: <4E8B40A3.2010103@CyberTools.biz> <4E8B4742.8040409@ice-sa.com> <4E8B5484.5030203@christopherschultz.net> <4E8B59C8.7010006@christopherschultz.net> <4E8B613E.2050203@ice-sa.com> <4E8B71A5.6020802@ice-sa.com> <4E8B738C.2030605@christopherschultz.net> <4E8B7F11.4090807@ice-sa.com> In-Reply-To: <4E8B7F11.4090807@ice-sa.com> X-Enigmail-Version: 1.3.2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 André, On 10/4/2011 5:48 PM, André Warnier wrote: > Yes, because if one defines e.g. a Pattern "^abcdef" and uses it > via yesno = Pattern.matches("^abcdef",input); it will actually > match the pattern at the beginning of the string only, which is > what one would expect. Thus > > Pattern.matches("^abc","abcdef"); > > would return true, while this : > > Pattern.compile("^abc").matcher("abcdef").matches() > > would return false (according to what I read in the documentation > of Matcher.matches()). Not so ? I'm not sure how Pattern.matches() would be different than Pattern.matcher().matches(), given that it is documented to be identical. >>> So my question is : which of Matcher or Pattern is really used >>> in the Valve's code ? >> >> You could read the code :) > > Do you mean to say that trying to configure Tomcat according to > the online documentation, with the purpose of using it as a > servlet container, is reserved exclusively for java programmers ? > ;-) No, I meant to say that you've been around long enough that you don't have to speculate. > I guess that what I have trouble understanding here, is how the > Java regex library can go about allowing to create a Pattern like > "^abc", and then using it in a Matcher.matches() method, completely > ignoring the anchors which it accepted in the Pattern and silently > inserting its own. It can and should, because it's documented to do so. Nobody is saying it's the "right" thing to do... just that it's what it does do. > But then, how come they are not, in the allow/deny of the Valve ? Because of the choice to use Matcher.matches() instead of something more nuanced. > Does the Valve code itself strip any provided anchors, and "force" > ^ and $ around the expression provided in the allow/deny attributes > ? No, it keeps them in-tact. It's the library that essentially ignores them. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6LhOQACgkQ9CaO5/Lv0PBFfwCfcT5d7reodusMTNR2GgWvBoZx wigAoLKwFDgE1p7ijEPxnpn2rFCwbAYT =kZqV -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org