From 761feabd79ccb7cea3910147b5c6064404441dbf Mon Sep 17 00:00:00 2001 From: maxcooper Date: Mon, 9 Dec 2002 12:23:03 +0000 Subject: [PATCH] fixed various pattern matching problems, including: /foo/* not matching /foo /bar/* matching /foo/bar/index.html *.ext matching *.extention /exact matching /exact/morestuff.html --- .../securityfilter/filter/MatchableURLPattern.java | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/share/org/securityfilter/filter/MatchableURLPattern.java b/src/share/org/securityfilter/filter/MatchableURLPattern.java index 4e48537..28b86cf 100644 --- a/src/share/org/securityfilter/filter/MatchableURLPattern.java +++ b/src/share/org/securityfilter/filter/MatchableURLPattern.java @@ -1,7 +1,7 @@ /* - * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/filter/Attic/MatchableURLPattern.java,v 1.5 2002/09/14 08:45:28 maxcooper Exp $ - * $Revision: 1.5 $ - * $Date: 2002/09/14 08:45:28 $ + * $Header: /cvsroot/securityfilter/securityfilter/src/share/org/securityfilter/filter/Attic/MatchableURLPattern.java,v 1.6 2002/12/09 12:23:03 maxcooper Exp $ + * $Revision: 1.6 $ + * $Date: 2002/12/09 12:23:03 $ * * ==================================================================== * The SecurityFilter Software License, Version 1.1 @@ -69,7 +69,7 @@ import java.util.Collection; * by the order field). * * @author Max Cooper (max@maxcooper.com) - * @version $Revision: 1.5 $ $Date: 2002/09/14 08:45:28 $ + * @version $Revision: 1.6 $ $Date: 2002/12/09 12:23:03 $ */ public class MatchableURLPattern implements Comparable { private String pattern; @@ -303,6 +303,23 @@ public class MatchableURLPattern implements Comparable { buf.replace(pos, pos + 1, ".*"); pos = buf.toString().indexOf('*', pos + 2); } + // adjustments for the different expression types + switch (patternType) { + case PATH: + // make sure it matches from the start of the string + buf.insert(0, '^'); + // make sure /foo/* matches /foo and /foo/morestuff, but not /foobar + buf.insert(buf.length()-3, "($|"); + buf.append(")"); + break; + case EXTENSION: + buf.append('$'); + break; + case EXACT: + buf.insert(0, '^'); + buf.append('$'); + break; + } return buf.toString(); } } -- 2.11.0