Index: /home/metskem/workspace/JSPWiki/.classpath
===================================================================
--- /home/metskem/workspace/JSPWiki/.classpath	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/.classpath	(working copy)
@@ -12,7 +12,6 @@
 	<classpathentry kind="lib" path="tests/lib/xercesImpl-2.6.2.jar"/>
 	<classpathentry kind="lib" path="lib/sandler.jar"/>
 	<classpathentry kind="lib" path="lib/oscache.jar"/>
-	<classpathentry kind="lib" path="lib/oro.jar"/>
 	<classpathentry kind="lib" path="lib/nekohtml.jar"/>
 	<classpathentry kind="lib" path="lib/lucene.jar"/>
 	<classpathentry kind="lib" path="tests/lib/junit.jar"/>
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/filters/SpamFilter.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/filters/SpamFilter.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/filters/SpamFilter.java	(working copy)
@@ -22,6 +22,10 @@
 
 import java.io.*;
 import java.util.*;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -35,7 +39,6 @@
 import org.apache.jspwiki.api.ModuleData;
 import com.ecyrd.jspwiki.log.Logger;
 import com.ecyrd.jspwiki.log.LoggerFactory;
-import org.apache.oro.text.regex.*;
 
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.action.WikiContextFactory;
@@ -143,9 +146,6 @@
     private String          m_errorPage          = "RejectedMessage";
     private String          m_blacklist          = "SpamFilterWordList/blacklist.txt";
 
-    private PatternMatcher  m_matcher = new Perl5Matcher();
-    private PatternCompiler m_compiler = new Perl5Compiler();
-
     private Collection<Pattern> m_spamPatterns = null;
 
     private Date            m_lastRebuild = new Date( 0L );
@@ -240,9 +240,9 @@
 
         try
         {
-            m_urlPattern = m_compiler.compile( URL_REGEXP );
+            m_urlPattern = Pattern.compile( URL_REGEXP );
         }
-        catch( MalformedPatternException e )
+        catch( PatternSyntaxException e )
         {
             log.error("Internal error: Someone put in a faulty pattern.",e);
             throw new InternalWikiException("Faulty pattern.");
@@ -367,9 +367,9 @@
 
                 try
                 {
-                    compiledpatterns.add( m_compiler.compile( pattern ) );
+                    compiledpatterns.add( Pattern.compile( pattern ) );
                 }
-                catch( MalformedPatternException e )
+                catch( PatternSyntaxException e )
                 {
                     log.debug( "Malformed spam filter pattern "+pattern );
 
@@ -414,9 +414,9 @@
 
                     try
                     {
-                        compiledpatterns.add( m_compiler.compile( line ) );
+                        compiledpatterns.add( Pattern.compile( line ) );
                     }
-                    catch( MalformedPatternException e )
+                    catch( PatternSyntaxException e )
                     {
                         log.debug( "Malformed spam filter pattern "+line );
                     }
@@ -520,11 +520,12 @@
             String tstChange = change;
             int    urlCounter = 0;
 
-            while( m_matcher.contains(tstChange,m_urlPattern) )
+            Matcher matcher = m_urlPattern.matcher( tstChange );
+            while( matcher.find() )
             {
-                MatchResult m = m_matcher.getMatch();
+                MatchResult m = matcher.toMatchResult();
 
-                tstChange = tstChange.substring( m.endOffset(0) );
+                tstChange = tstChange.substring( m.end(0) );
 
                 urlCounter++;
             }
@@ -853,7 +854,8 @@
         {
             // log.debug("Attempting to match page contents with "+p.getPattern());
 
-            if( m_matcher.contains( change, p ) )
+            Matcher matcher = p.matcher( change );
+            if( matcher.find( ) )
             {
                 //
                 //  Spam filter has a match.
@@ -858,11 +860,11 @@
                 //
                 //  Spam filter has a match.
                 //
-                String uid = log( context, REJECT, REASON_REGEXP+"("+p.getPattern()+")", change);
+                String uid = log( context, REJECT, REASON_REGEXP+"("+p.pattern()+")", change);
 
-                log.info("SPAM:Regexp ("+uid+"). Content matches the spam filter '"+p.getPattern()+"'");
+                log.info("SPAM:Regexp ("+uid+"). Content matches the spam filter '"+p.pattern()+"'");
 
-                checkStrategy( context, REASON_REGEXP, "Herb says '"+p.getPattern()+"' is a bad spam word and I trust Herb! (Incident code "+uid+")");
+                checkStrategy( context, REASON_REGEXP, "Herb says '"+p.pattern()+"' is a bad spam word and I trust Herb! (Incident code "+uid+")");
             }
         }
     }
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/parser/JSPWikiMarkupParser.java	(working copy)
@@ -25,6 +25,10 @@
 import java.io.StringReader;
 import java.text.MessageFormat;
 import java.util.*;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.xml.transform.Result;
@@ -32,8 +36,6 @@
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.jspwiki.api.PluginException;
-import org.apache.oro.text.GlobCompiler;
-import org.apache.oro.text.regex.*;
 import org.jdom.*;
 
 import com.ecyrd.jspwiki.*;
@@ -49,6 +51,7 @@
 import com.ecyrd.jspwiki.providers.ProviderException;
 import com.ecyrd.jspwiki.render.CleanTextRenderer;
 import com.ecyrd.jspwiki.render.RenderingManager;
+import com.ecyrd.jspwiki.util.RegExpUtil;
 import com.ecyrd.jspwiki.util.TextUtil;
 
 /**
@@ -115,8 +118,6 @@
     /** Parser for extended link functionality. */
     private LinkParser     m_linkParser = new LinkParser();
 
-    private PatternMatcher m_inlineMatcher = new Perl5Matcher();
-
     /** Keeps track of any plain text that gets put in the Text nodes */
     private StringBuilder  m_plainTextBuf = new StringBuilder(20);
 
@@ -167,11 +168,9 @@
 
     private boolean                m_useRelNofollow      = false;
 
-    private PatternCompiler        m_compiler = new Perl5Compiler();
-
-    static final String WIKIWORD_REGEX = "(^|[[:^alnum:]]+)([[:upper:]]+[[:lower:]]+[[:upper:]]+[[:alnum:]]*|(http://|https://|mailto:)([A-Za-z0-9_/\\.\\+\\?\\#\\-\\@=&;~%]+))";
+//    static final String WIKIWORD_REGEX = "(^|[[:^alnum:]]+)([[:upper:]]+[[:lower:]]+[[:upper:]]+[[:alnum:]]*|(http://|https://|mailto:)([A-Za-z0-9_/\\.\\+\\?\\#\\-\\@=&;~%]+))";
+    static final String WIKIWORD_REGEX = "(^|[[^\\p{Alnum}]]+)([[\\p{Upper}]]+[[\\p{Lower}]]+[[\\p{Upper}]]+[[\\p{Alnum}]]*|(http://|https://|mailto:)([A-Za-z0-9_/\\.\\+\\?\\#\\-\\@=&;~%]+))";
 
-    private PatternMatcher         m_camelCaseMatcher = new Perl5Matcher();
     private Pattern                m_camelCasePattern;
 
     private int                    m_rowNum              = 1;
@@ -256,7 +255,6 @@
     @SuppressWarnings("unchecked")
     private void initialize()
     {
-        PatternCompiler compiler         = new GlobCompiler();
         List<Pattern>   compiledpatterns;
 
         //
@@ -278,10 +276,10 @@
             {
                 try
                 {
-                    compiledpatterns.add( compiler.compile( (String)i.next(),
-                                                            GlobCompiler.DEFAULT_MASK|GlobCompiler.READ_ONLY_MASK ) );
+                    compiledpatterns.add( Pattern.compile( RegExpUtil
+                        .globToPerl5( ((String) i.next()).toCharArray(), RegExpUtil.DEFAULT_MASK|RegExpUtil.READ_ONLY_MASK ) ) );
                 }
-                catch( MalformedPatternException e )
+                catch( PatternSyntaxException e )
                 {
                     log.error("Malformed pattern in properties: ", e );
                 }
@@ -297,10 +295,9 @@
         {
             try
             {
-                m_camelCasePattern = m_compiler.compile( WIKIWORD_REGEX,
-                                                         Perl5Compiler.DEFAULT_MASK|Perl5Compiler.READ_ONLY_MASK );
+                m_camelCasePattern = Pattern.compile( WIKIWORD_REGEX, RegExpUtil.DEFAULT_MASK | RegExpUtil.READ_ONLY_MASK );
             }
-            catch( MalformedPatternException e )
+            catch( PatternSyntaxException e )
             {
                 log.error("Internal error: Someone put in a faulty pattern.",e);
                 throw new InternalWikiException("Faulty camelcasepattern in TranslatorReader");
@@ -694,7 +691,8 @@
 
             for( Iterator i = m_inlineImagePatterns.iterator(); i.hasNext(); )
             {
-                if( m_inlineMatcher.matches( link, (Pattern) i.next() ) )
+                Matcher matcher = ((Pattern) i.next()).matcher( link );
+                if( matcher.matches() )
                     return true;
             }
         }
@@ -801,13 +799,14 @@
 
                 if( m_camelCaseLinks && !m_isEscaping && buf.length() > 3 )
                 {
-                    // System.out.println("Buffer="+buf);
-
-                    while( m_camelCaseMatcher.contains( buf, m_camelCasePattern ) )
+                    Matcher camelCaseMatcher = null;
+                    while (( camelCaseMatcher =  m_camelCasePattern.matcher( buf )).find())
                     {
-                        MatchResult result = m_camelCaseMatcher.getMatch();
-
-                        String firstPart = buf.substring(0,result.beginOffset(0));
+                        MatchResult result = camelCaseMatcher.toMatchResult();
+                        
+                        System.out.print(buf);
+                        System.out.println(" " + result.start() + "  "  + result.start(0));
+                        String firstPart = buf.substring(0,result.start());
                         String prefix = result.group(1);
 
                         if( prefix == null ) prefix = "";
@@ -815,10 +814,10 @@
                         String camelCase = result.group(2);
                         String protocol  = result.group(3);
                         String uri       = protocol+result.group(4);
-                        buf              = buf.substring(result.endOffset(0));
+                        buf              = buf.substring(result.end());
 
                         m_currentElement.addContent( firstPart );
-
+                        result.group(2);
                         //
                         //  Check if the user does not wish to do URL or WikiWord expansion
                         //
@@ -3015,6 +3014,4 @@
 
     }
 
-
 }
-
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/AbstractReferralPlugin.java	(working copy)
@@ -23,11 +23,12 @@
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.jspwiki.api.PluginException;
-import org.apache.oro.text.GlobCompiler;
-import org.apache.oro.text.regex.*;
 
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.log.Logger;
@@ -37,6 +38,7 @@
 import com.ecyrd.jspwiki.preferences.Preferences;
 import com.ecyrd.jspwiki.preferences.Preferences.TimeFormat;
 import com.ecyrd.jspwiki.render.RenderingManager;
+import com.ecyrd.jspwiki.util.RegExpUtil;
 import com.ecyrd.jspwiki.util.TextUtil;
 
 /**
@@ -99,7 +101,7 @@
     protected           String   m_separator = ""; // null not blank
     protected           String   m_after = "\\\\";
 
-    protected           Pattern[]  m_exclude;
+    protected           Pattern[] m_exclude;
     protected           Pattern[]  m_include;
     
     protected           String m_show = "pages";
@@ -155,8 +157,6 @@
         {
             try
             {
-                PatternCompiler pc = new GlobCompiler();
-
                 String[] ptrns = StringUtils.split( s, "," );
 
                 m_exclude = new Pattern[ptrns.length];
@@ -163,10 +163,12 @@
 
                 for( int i = 0; i < ptrns.length; i++ )
                 {
-                    m_exclude[i] = pc.compile( ptrns[i] );
+                    m_exclude[i] = Pattern
+                        .compile( RegExpUtil.globToPerl5( ptrns[i].toCharArray(),
+                                                                        RegExpUtil.DEFAULT_MASK ) );
                 }
             }
-            catch( MalformedPatternException e )
+            catch(PatternSyntaxException e )
             {
                 throw new PluginException("Exclude-parameter has a malformed pattern: "+e.getMessage());
             }
@@ -179,8 +181,6 @@
         {
             try
             {
-                PatternCompiler pc = new GlobCompiler();
-
                 String[] ptrns = StringUtils.split( s, "," );
 
                 m_include = new Pattern[ptrns.length];
@@ -187,10 +187,12 @@
 
                 for( int i = 0; i < ptrns.length; i++ )
                 {
-                    m_include[i] = pc.compile( ptrns[i] );
+                    m_include[i] = Pattern
+                        .compile( RegExpUtil.globToPerl5( ptrns[i].toCharArray(),
+                                                                        RegExpUtil.DEFAULT_MASK ) );
                 }
             }
-            catch( MalformedPatternException e )
+            catch( PatternSyntaxException e )
             {
                 throw new PluginException("Include-parameter has a malformed pattern: "+e.getMessage());
             }
@@ -235,8 +237,6 @@
     {
         ArrayList<String> result = new ArrayList<String>();
 
-        PatternMatcher pm = new Perl5Matcher();
-
         for( Iterator i = c.iterator(); i.hasNext(); )
         {
             String pageName = (String) i.next();
@@ -253,7 +253,8 @@
             {
                 for( int j = 0; j < m_include.length; j++ )
                 {
-                    if( pm.matches( pageName, m_include[j] ) )
+                    Matcher matcher = m_include[j].matcher( pageName );
+                    if( matcher.matches() )
                     {
                         includeThis = true;
                         break;
@@ -265,7 +266,8 @@
             {
                 for( int j = 0; j < m_exclude.length; j++ )
                 {
-                    if( pm.matches( pageName, m_exclude[j] ) )
+                    Matcher matcher = m_exclude[j].matcher( pageName );
+                    if( matcher.matches() )
                     {
                         includeThis = false;
                         break; // The inner loop, continue on the next item
@@ -277,7 +279,7 @@
             {
                 result.add( pageName );
                 //
-                //  if we want to show the last modified date of the most recently change page, we keep a "high watermark" here:
+                //  if we want to show the last modified date of the most recently changed page, we keep a "high watermark" here:
                 WikiPage page = null;
                 if( m_lastModified )
                 {
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/IfPlugin.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/IfPlugin.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/IfPlugin.java	(working copy)
@@ -23,6 +23,8 @@
 
 import java.security.Principal;
 import java.util.Map;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.jspwiki.api.ModuleData;
@@ -27,7 +29,6 @@
 import org.apache.commons.lang.StringUtils;
 import org.apache.jspwiki.api.ModuleData;
 import org.apache.jspwiki.api.PluginException;
-import org.apache.oro.text.regex.*;
 
 import com.ecyrd.jspwiki.WikiContext;
 import com.ecyrd.jspwiki.WikiProvider;
@@ -269,16 +270,13 @@
     private static boolean doMatch( String content, String pattern )
         throws PluginException
     {
-        PatternCompiler compiler = new Perl5Compiler();
-        PatternMatcher  matcher  = new Perl5Matcher();
-
         try
         {
-            Pattern matchp = compiler.compile( pattern, Perl5Compiler.SINGLELINE_MASK );
+            Pattern matchPattern = Pattern.compile( pattern );
             // m_exceptPattern = compiler.compile( exceptPattern, Perl5Compiler.SINGLELINE_MASK );
-            return matcher.matches( content, matchp );
+            return matchPattern.matcher(content).matches( );
         }
-        catch( MalformedPatternException e )
+        catch( PatternSyntaxException e )
         {
             throw new PluginException("Faulty pattern "+pattern);
         }
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/PluginManager.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/PluginManager.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/PluginManager.java	(working copy)
@@ -24,6 +24,10 @@
 import java.lang.reflect.Modifier;
 import java.text.MessageFormat;
 import java.util.*;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import net.sourceforge.stripes.util.ResolverUtil;
 
@@ -31,7 +35,6 @@
 import org.apache.ecs.xhtml.*;
 import org.apache.jspwiki.api.ModuleData;
 import org.apache.jspwiki.api.PluginException;
-import org.apache.oro.text.regex.*;
 
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.log.Logger;
@@ -208,13 +211,11 @@
         m_searchPath.add( DEFAULT_PACKAGE );
         m_searchPath.add( DEFAULT_FORMS_PACKAGE );
 
-        PatternCompiler compiler = new Perl5Compiler();
-
         try
         {
-            m_pluginPattern = compiler.compile( PLUGIN_INSERT_PATTERN );
+            m_pluginPattern =Pattern.compile( PLUGIN_INSERT_PATTERN );
         }
-        catch( MalformedPatternException e )
+        catch( PatternSyntaxException e )
         {
             log.error("Internal error: someone messed with pluginmanager patterns.", e );
             throw new InternalWikiException( "PluginManager patterns are broken" );
@@ -564,16 +565,16 @@
 
         ResourceBundle rb = context.getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
         Object[] obArgs = { commandline };
-        PatternMatcher  matcher  = new Perl5Matcher();
+        Matcher  matcher  = m_pluginPattern.matcher( commandline );
 
         try
         {
-            if( matcher.contains( commandline, m_pluginPattern ) )
+            if( matcher.find( ) )
             {
-                MatchResult res = matcher.getMatch();
+                MatchResult res = matcher.toMatchResult();
 
                 String plugin   = res.group(2);
-                String args     = commandline.substring(res.endOffset(0),
+                String args     = commandline.substring(res.end(),
                                                         commandline.length() -
                                                         (commandline.charAt(commandline.length()-1) == '}' ? 1 : 0 ) );
                 Map arglist     = parseArgs( args );
@@ -613,16 +614,16 @@
    public PluginContent parsePluginLine( WikiContext context, String commandline, int pos )
         throws PluginException
     {
-        PatternMatcher  matcher  = new Perl5Matcher();
+        Matcher  matcher  = m_pluginPattern.matcher( commandline );
 
         try
         {
-            if( matcher.contains( commandline, m_pluginPattern ) )
+            if( matcher.find() )
             {
-                MatchResult res = matcher.getMatch();
+                MatchResult res = matcher.toMatchResult();
 
                 String plugin   = res.group(2);
-                String args     = commandline.substring(res.endOffset(0),
+                String args     = commandline.substring(res.end(0),
                                                         commandline.length() -
                                                         (commandline.charAt(commandline.length()-1) == '}' ? 1 : 0 ) );
                 Map<String, Object> arglist = parseArgs( args );
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/ReferredPagesPlugin.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/ReferredPagesPlugin.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/plugin/ReferredPagesPlugin.java	(working copy)
@@ -21,9 +21,10 @@
 package com.ecyrd.jspwiki.plugin;
 
 import java.util.*;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import org.apache.jspwiki.api.PluginException;
-import org.apache.oro.text.regex.*;
 
 import com.ecyrd.jspwiki.*;
 import com.ecyrd.jspwiki.log.Logger;
@@ -37,7 +38,6 @@
  *  <p>Parameters</p>
  *  <ul>
  *    <li><b>name</b> - Name of the root page. Default name of calling page
- *    <li><b>type</b> - local|externalattachment
  *    <li><b>depth</b> - How many levels of pages to be parsed.
  *    <li><b>include</b> - Include only these pages. (eg. include='UC.*|BP.*' )
  *    <li><b>exclude</b> - Exclude with this pattern. (eg. exclude='LeftMenu' )
@@ -53,7 +53,6 @@
     private int            m_depth;
     private HashSet<String> m_exists  = new HashSet<String>();
     private StringBuilder   m_result  = new StringBuilder(1024);
-    private PatternMatcher m_matcher = new Perl5Matcher();
     private Pattern        m_includePattern;
     private Pattern        m_excludePattern;
     private boolean m_formatCompact  = true;
@@ -65,9 +64,6 @@
     /** The parameter name for the depth.  Value is <tt>{@value}</tt>. */
     public static final String PARAM_DEPTH   = "depth";
 
-    /** The parameter name for the type of the references.  Value is <tt>{@value}</tt>. */
-    public static final String PARAM_TYPE    = "type";
-    
     /** The parameter name for the included pages.  Value is <tt>{@value}</tt>. */
     public static final String PARAM_INCLUDE = "include";
     
@@ -136,15 +132,14 @@
         // glob compiler :  * is 0..n instance of any char  -- more convenient as input
         // perl5 compiler : .* is 0..n instances of any char -- more powerful
         //PatternCompiler g_compiler = new GlobCompiler();
-        PatternCompiler compiler = new Perl5Compiler();
 
         try
         {
-            m_includePattern = compiler.compile(includePattern);
+            m_includePattern = Pattern.compile(includePattern);
 
-            m_excludePattern = compiler.compile(excludePattern);
+            m_excludePattern = Pattern.compile(excludePattern);
         }
-        catch( MalformedPatternException e )
+        catch( PatternSyntaxException e )
         {
             if (m_includePattern == null )
             {
@@ -214,8 +209,8 @@
             if( !m_engine.pageExists( link ) ) continue; // hide links to non
                                                          // existing pages
 
-            if(  m_matcher.matches( link , m_excludePattern ) ) continue;
-            if( !m_matcher.matches( link , m_includePattern ) ) continue;
+            if( m_excludePattern.matcher( link ).find()) continue;
+            if( !m_includePattern.matcher( link ).find() ) continue;
 
             if( m_exists.contains( link ) )
             {
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java	(revision 727418)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/providers/RCSFileProvider.java	(working copy)
@@ -30,6 +30,10 @@
 import java.util.List;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.regex.MatchResult;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 import java.text.SimpleDateFormat;
 import java.text.ParseException;
 import com.ecyrd.jspwiki.log.Logger;
@@ -37,8 +41,6 @@
 import com.ecyrd.jspwiki.util.FileUtil;
 import com.ecyrd.jspwiki.util.TextUtil;
 
-import org.apache.oro.text.regex.*;
-
 import com.ecyrd.jspwiki.*;
 
 /**
@@ -134,8 +136,7 @@
     public WikiPage getPageInfo( String page, int version )
         throws ProviderException
     {
-        PatternMatcher  matcher  = new Perl5Matcher();
-        PatternCompiler compiler = new Perl5Compiler();
+        Matcher  matcher  = null;
         BufferedReader  stdout   = null;
 
         WikiPage info = super.getPageInfo( page, version );
@@ -154,12 +155,12 @@
             stdout = new BufferedReader( new InputStreamReader(process.getInputStream() ) );
 
             String line;
-            Pattern headpattern = compiler.compile( PATTERN_REVISION );
+            Pattern headpattern = Pattern.compile( PATTERN_REVISION );
             // This complicated pattern is required, since on Linux RCS adds
             // quotation marks, but on Windows, it does not.
-            Pattern userpattern = compiler.compile( PATTERN_AUTHOR );
-            Pattern datepattern = compiler.compile( PATTERN_DATE );
-            Pattern notepattern = compiler.compile( PATTERN_CHANGENOTE );
+            Pattern userpattern = Pattern.compile( PATTERN_AUTHOR );
+            Pattern datepattern = Pattern.compile( PATTERN_DATE );
+            Pattern notepattern = Pattern.compile( PATTERN_CHANGENOTE );
 
             boolean found = false;
 
@@ -165,9 +166,10 @@
 
             while( (line = stdout.readLine()) != null )
             {
-                if( matcher.contains( line, headpattern ) )
+                matcher = headpattern.matcher( line ); 
+                if( matcher.find() )
                 {
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
 
                     try
                     {
@@ -185,9 +187,11 @@
                         // Just continue reading through
                     }
                 }
-                else if( matcher.contains( line, datepattern ) && found )
+                else
+                    matcher = datepattern.matcher( line );
+                    if( matcher.find() && found )
                 {
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
                     Date d = parseDate( result.group(1) );
 
                     if( d != null )
@@ -207,17 +211,19 @@
                     break;
                 }
 
-                if( found && matcher.contains( line, userpattern ) )
+                matcher = userpattern.matcher( line );
+                if( found && matcher.find() )
                 {
-                    MatchResult result = matcher.getMatch();
-                    info.setAuthor( TextUtil.urlDecodeUTF8(result.group(1)) );
+                    MatchResult result = matcher.toMatchResult();
+                    info.setAuthor( TextUtil.urlDecodeUTF8( result.group( 1 ) ) );
                 }
 
-                if( found && matcher.contains( line, notepattern ) )
+                matcher = notepattern.matcher( line );
+                if( found && matcher.find() )
                 {
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
 
-                    info.setAttribute( WikiPage.CHANGENOTE, TextUtil.urlDecodeUTF8(result.group(1)) );
+                    info.setAttribute( WikiPage.CHANGENOTE, TextUtil.urlDecodeUTF8( result.group( 1 ) ) );
                 }
             }
 
@@ -277,8 +283,7 @@
 
         try
         {
-            PatternMatcher  matcher           = new Perl5Matcher();
-            PatternCompiler compiler          = new Perl5Compiler();
+            Matcher  matcher           = null;;
             int             checkedOutVersion = -1;
             String          line;
             String          cmd               = m_checkoutVersionCommand;
@@ -294,13 +299,14 @@
 
             stderr = new BufferedReader(new InputStreamReader(process.getErrorStream()));
 
-            Pattern headpattern = compiler.compile( PATTERN_REVISION );
+            Pattern headpattern = Pattern.compile( PATTERN_REVISION );
 
             while( (line = stderr.readLine()) != null )
             {
-                if( matcher.contains( line, headpattern ) )
+                matcher = headpattern.matcher( line );
+                if( matcher.find() )
                 {
-                    MatchResult mr = matcher.getMatch();
+                    MatchResult mr = matcher.toMatchResult();
                     checkedOutVersion = Integer.parseInt( mr.group(1) );
                 }
             }
@@ -341,7 +347,7 @@
             }
 
         }
-        catch( MalformedPatternException e )
+        catch( PatternSyntaxException e )
         {
             throw new InternalWikiException("Malformed pattern in RCSFileProvider!");
         }
@@ -465,8 +471,7 @@
     // FIXME: Put the rcs date formats into properties as well.
     public List getVersionHistory( String page )
     {
-        PatternMatcher matcher = new Perl5Matcher();
-        PatternCompiler compiler = new Perl5Compiler();
+        Matcher matcher =null;
         BufferedReader stdout  = null;
 
         log.debug("Getting RCS version history");
@@ -475,13 +480,13 @@
 
         try
         {
-            Pattern revpattern  = compiler.compile( PATTERN_REVISION );
-            Pattern datepattern = compiler.compile( PATTERN_DATE );
+            Pattern revpattern  = Pattern.compile( PATTERN_REVISION );
+            Pattern datepattern = Pattern.compile( PATTERN_DATE );
             // This complicated pattern is required, since on Linux RCS adds
             // quotation marks, but on Windows, it does not.
-            Pattern userpattern = compiler.compile( PATTERN_AUTHOR );
+            Pattern userpattern = Pattern.compile( PATTERN_AUTHOR );
 
-            Pattern notepattern = compiler.compile( PATTERN_CHANGENOTE );
+            Pattern notepattern = Pattern.compile( PATTERN_CHANGENOTE );
 
             String cmd = TextUtil.replaceString( m_fullLogCommand,
                                                  "%s",
@@ -498,11 +503,12 @@
 
             while( (line = stdout.readLine()) != null )
             {
-                if( matcher.contains( line, revpattern ) )
+                matcher = revpattern.matcher( line );
+                if( matcher.find() )
                 {
                     info = new WikiPage( m_engine, page );
 
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
 
                     int vernum = Integer.parseInt( result.group(1) );
                     info.setVersion( vernum );
@@ -510,9 +516,10 @@
                     list.add( info );
                 }
 
-                if( matcher.contains( line, datepattern ) && info != null )
+                matcher = datepattern.matcher( line );
+                if( matcher.find() && info != null )
                 {
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
 
                     Date d = parseDate( result.group(1) );
 
@@ -519,9 +526,10 @@
                     info.setLastModified( d );
                 }
 
-                if( matcher.contains( line, userpattern ) && info != null )
+                matcher = userpattern.matcher( line );
+                if( matcher.find() && info != null )
                 {
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
 
                     info.setAuthor( TextUtil.urlDecodeUTF8(result.group(1)) );
                 }
@@ -526,9 +534,10 @@
                     info.setAuthor( TextUtil.urlDecodeUTF8(result.group(1)) );
                 }
 
-                if( matcher.contains( line, notepattern ) && info != null )
+                matcher = notepattern.matcher( line );
+                if( matcher.find() && info != null )
                 {
-                    MatchResult result = matcher.getMatch();
+                    MatchResult result = matcher.toMatchResult();
 
                     info.setAttribute( WikiPage.CHANGENOTE, TextUtil.urlDecodeUTF8(result.group(1)) );
                 }
Index: /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/util/RegExpUtil.java
===================================================================
--- /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/util/RegExpUtil.java	(revision 0)
+++ /home/metskem/workspace/JSPWiki/src/com/ecyrd/jspwiki/util/RegExpUtil.java	(revision 0)
@@ -0,0 +1,189 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+    
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.  
+*/
+package com.ecyrd.jspwiki.util;
+
+/**
+ * Copied code from the org.apache.oro.text.regex.GlobCompiler
+ * All credits to the author's
+ */
+public final class RegExpUtil
+{
+    private RegExpUtil()
+    {
+        // private constructor prevents construction
+    }
+
+    /**
+     * The default mask for the {@link #compile compile} methods. It is equal to
+     * 0. The default behavior is for a glob expression to be case sensitive
+     * unless it is compiled with the CASE_INSENSITIVE_MASK option.
+     */
+    public static final int DEFAULT_MASK = 0;
+
+    /**
+     * A mask passed as an option to the {@link #compile compile} methods to
+     * indicate a compiled glob expression should be case insensitive.
+     */
+    public static final int CASE_INSENSITIVE_MASK = 0x0001;
+
+    /**
+     * A mask passed as an option to the {@link #compile compile} methods to
+     * indicate that a * should not be allowed to match the null string. The
+     * normal behavior of the * metacharacter is that it may match any 0 or more
+     * characters. This mask causes it to match 1 or more characters of
+     * anything.
+     */
+    public static final int STAR_CANNOT_MATCH_NULL_MASK = 0x0002;
+
+    /**
+     * A mask passed as an option to the {@link #compile compile} methods to
+     * indicate that a ? should not be allowed to match the null string. The
+     * normal behavior of the ? metacharacter is that it may match any 1
+     * character. This mask causes it to match 0 or 1 characters.
+     */
+    public static final int QUESTION_MATCHES_ZERO_OR_ONE_MASK = 0x0004;
+
+    /**
+     * A mask passed as an option to the {@link #compile compile} methods to
+     * indicate that the resulting Perl5Pattern should be treated as a read only
+     * data structure by Perl5Matcher, making it safe to share a single
+     * Perl5Pattern instance among multiple threads without needing
+     * synchronization. Without this option, Perl5Matcher reserves the right to
+     * store heuristic or other information in Perl5Pattern that might
+     * accelerate future matches. When you use this option, Perl5Matcher will
+     * not store or modify any information in a Perl5Pattern. Use this option
+     * when you want to share a Perl5Pattern instance among multiple threads
+     * using different Perl5Matcher instances.
+     */
+    public static final int READ_ONLY_MASK = 0x0008;
+
+    /**
+     * This static method is the basic engine of the Glob PatternCompiler
+     * implementation. It takes a glob expression in the form of a character
+     * array and converts it into a String representation of a Perl5 pattern.
+     * The method is made public so that programmers may use it for their own
+     * purposes. However, the GlobCompiler compile methods work by converting
+     * the glob pattern to a Perl5 pattern using this method, and then invoking
+     * the compile() method of an internally stored Perl5Compiler instance.
+     * <p>
+     * 
+     * @param pattern A character array representation of a Glob pattern.
+     * @return A String representation of a Perl5 pattern equivalent to the Glob
+     *         pattern.
+     */
+    public static String globToPerl5( char[] pattern, int options )
+    {
+        boolean inCharSet = false;
+        boolean starCannotMatchNull = false;
+        boolean questionMatchesZero = false;
+        
+        int ch;
+        StringBuffer buffer;
+
+        buffer = new StringBuffer( 2 * pattern.length );
+        inCharSet = false;
+
+        questionMatchesZero = (options & QUESTION_MATCHES_ZERO_OR_ONE_MASK) != 0;
+        starCannotMatchNull = (options & STAR_CANNOT_MATCH_NULL_MASK) != 0;
+
+        for( ch = 0; ch < pattern.length; ch++ )
+        {
+            switch( pattern[ch] )
+            {
+                case '*':
+                    if( inCharSet )
+                        buffer.append( '*' );
+                    else
+                    {
+                        if( starCannotMatchNull )
+                            buffer.append( ".+" );
+                        else
+                            buffer.append( ".*" );
+                    }
+                    break;
+                case '?':
+                    if( inCharSet )
+                        buffer.append( '?' );
+                    else
+                    {
+                        if( questionMatchesZero )
+                            buffer.append( ".?" );
+                        else
+                            buffer.append( '.' );
+                    }
+                    break;
+                case '[':
+                    inCharSet = true;
+                    buffer.append( pattern[ch] );
+
+                    if( ch + 1 < pattern.length )
+                    {
+                        switch( pattern[ch + 1] )
+                        {
+                            case '!':
+                            case '^':
+                                buffer.append( '^' );
+                                ++ch;
+                                continue;
+                            case ']':
+                                buffer.append( ']' );
+                                ++ch;
+                                continue;
+                        }
+                    }
+                    break;
+                case ']':
+                    inCharSet = false;
+                    buffer.append( pattern[ch] );
+                    break;
+                case '\\':
+                    buffer.append( '\\' );
+                    if( ch == pattern.length - 1 )
+                    {
+                        buffer.append( '\\' );
+                    }
+                    else if( isGlobMetaCharacter( pattern[ch + 1] ) )
+                        buffer.append( pattern[++ch] );
+                    else
+                        buffer.append( '\\' );
+                    break;
+                default:
+                    if( !inCharSet && isPerl5MetaCharacter( pattern[ch] ) )
+                        buffer.append( '\\' );
+                    buffer.append( pattern[ch] );
+                    break;
+            }
+        }
+
+        return buffer.toString();
+    }
+
+    private static boolean isPerl5MetaCharacter( char ch )
+    {
+        return "'*?+[]()|^$.{}\\".indexOf( ch ) >= 0;
+    }
+
+    private static boolean isGlobMetaCharacter( char ch )
+    {
+        return "*?[]".indexOf( ch ) >= 0;
+    }
+
+}
Index: /home/metskem/workspace/JSPWiki/tests/com/ecyrd/jspwiki/plugin/ReferredPagesPluginTest.java
===================================================================
--- /home/metskem/workspace/JSPWiki/tests/com/ecyrd/jspwiki/plugin/ReferredPagesPluginTest.java	(revision 0)
+++ /home/metskem/workspace/JSPWiki/tests/com/ecyrd/jspwiki/plugin/ReferredPagesPluginTest.java	(revision 0)
@@ -0,0 +1,128 @@
+/*
+    JSPWiki - a JSP-based WikiWiki clone.
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.    
+ */
+
+package com.ecyrd.jspwiki.plugin;
+
+import java.util.Properties;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.ecyrd.jspwiki.TestEngine;
+import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.WikiPage;
+
+public class ReferredPagesPluginTest extends TestCase
+{
+    Properties props = new Properties();
+
+    TestEngine engine;
+
+    WikiContext context;
+
+    PluginManager manager;
+
+    public ReferredPagesPluginTest( String s )
+    {
+        super( s );
+    }
+
+    public void setUp() throws Exception
+    {
+        props.load( TestEngine.findTestProperties() );
+
+        engine = new TestEngine( props );
+
+        engine.saveText( "SomeBodyPointsToMe", "Somebody points to this page" );
+        engine.saveText( "IPointToSomeoneElse", "Reference to [SomeBodyPointsToMe]." );
+        engine.saveText( "IPointToSomeoneElseToo", "Reference to [SomeBodyPointsToMe]." );
+        engine.saveText( "SomeBodyPointsToMeToo", "Somebody points to this page too" );
+        engine.saveText( "IPointToTwoPages", "Reference to [SomeBodyPointsToMe]  and   [SomeBodyPointsToMeToo]." );
+
+        context = engine.getWikiContextFactory().newViewContext( null, null, new WikiPage( engine, "IPointToSomeoneElse" ) );
+        manager = new PluginManager( engine, props );
+    }
+
+    public void tearDown()
+    {
+        TestEngine.deleteTestPage( "SomeBodyPointsToMe" );
+        TestEngine.deleteTestPage( "IPointToSomeoneElse" );
+        TestEngine.deleteTestPage( "IPointToSomeoneElseToo" );
+        TestEngine.deleteTestPage( "IPointToTwoPages" );
+    }
+
+    /**
+     * Plain test without parameters
+     * 
+     * @throws Exception
+     */
+    public void testReferredPage() throws Exception
+    {
+        context = engine.getWikiContextFactory().newViewContext( null, null, new WikiPage( engine, "IPointToSomeoneElse" ) );
+
+        String res = manager.execute( context, "{INSERT com.ecyrd.jspwiki.plugin.ReferredPagesPlugin}" );
+
+        assertEquals(
+                      "<div class=\"ReferredPagesPlugin\">\n<a class=\"wikipage\" href=\"/Wiki.jsp?page=IPointToSomeoneElse\" title=\"ReferredPagesPlugin: depth[1] include[.*] exclude[^$] format[compact]\">IPointToSomeoneElse</a>\n<ul>\n<li><a class=\"wikipage\" href=\"/Wiki.jsp?page=SomeBodyPointsToMe\">SomeBodyPointsToMe</a></li>\n</ul>\n</div>\n",
+                      res );
+    }
+
+    /**
+     * Test with the page parameter (page A tells us which pages page B points
+     * to)
+     * 
+     * @throws Exception
+     */
+    public void testReferredPageParmPage() throws Exception
+    {
+        context = engine.getWikiContextFactory().newViewContext( null, null, new WikiPage( engine, "IPointToSomeoneElse" ) );
+
+        String res = manager.execute( context, "{INSERT com.ecyrd.jspwiki.plugin.ReferredPagesPlugin page=IPointToSomeoneElseToo}" );
+
+        assertEquals(
+                      "<div class=\"ReferredPagesPlugin\">\n<a class=\"wikipage\" href=\"/Wiki.jsp?page=IPointToSomeoneElseToo\" title=\"ReferredPagesPlugin: depth[1] include[.*] exclude[^$] format[compact]\">IPointToSomeoneElseToo</a>\n<ul>\n<li><a class=\"wikipage\" href=\"/Wiki.jsp?page=SomeBodyPointsToMe\">SomeBodyPointsToMe</a></li>\n</ul>\n</div>\n",
+                      res );
+    }
+
+    /**
+     * Test with the include parameter
+     * 
+     * @throws Exception
+     */
+    public void testReferredPageParmInClude() throws Exception
+    {
+        context = engine.getWikiContextFactory().newViewContext( null, null, new WikiPage( engine, "IPointToTwoPages" ) );
+
+        String res = manager.execute( context,
+                                      "{INSERT com.ecyrd.jspwiki.plugin.ReferredPagesPlugin include='SomeBodyPointsToMe.*'}" );
+
+        assertEquals(
+                      "<div class=\"ReferredPagesPlugin\">\n<a class=\"wikipage\" href=\"/Wiki.jsp?page=IPointToTwoPages\" title=\"ReferredPagesPlugin: depth[1] include[SomeBodyPointsToMe.*] exclude[^$] format[compact]\">IPointToTwoPages</a>\n<ul>\n<li><a class=\"wikipage\" href=\"/Wiki.jsp?page=SomeBodyPointsToMe\">SomeBodyPointsToMe</a></li>\n<li><a class=\"wikipage\" href=\"/Wiki.jsp?page=SomeBodyPointsToMeToo\">SomeBodyPointsToMeToo</a></li>\n</ul>\n</div>\n",
+                      res );
+
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite( ReferredPagesPluginTest.class );
+    }
+}

