Yep. This is targeted for 2.0. The patch in itself is not really enough
because Anakia also uses oro. But java.util.regex and oro are actually
similar enough that rewriting isn't really a big thing.
Best regards
Henning
On Sun, 2005-10-30 at 14:04 -0800, Will Glass-Husain wrote:
> That makes sense. Goals for the 1.x releases remain 1.3 runtime, right? So
> this is a 2.0 item. Maybe we should file a JIRA issue as a reminder?
>
> The test classes also use Oro, but that's basically a build issue now that
> the test classes are separated.
>
> WILL
>
> ----- Original Message -----
> From: "Henning P. Schmiedehausen" <[EMAIL PROTECTED]>
> Newsgroups: hometree.jakarta.velocity.dev
> To: <[email protected]>
> Sent: Sunday, October 30, 2005 8:28 AM
> Subject: Interesting observation for the oro dependency
>
>
> > It seems that oro is used at only a single place in the whole velocity
> > tree: org.apache.velocity.app.event.implement.EscapeReference.
> >
> > Once we drop JDK 1.3 compatibility, we could simply apply the
> > following patch and remove oro from our runtime dependencies (not from
> > the tool dependencies, there are some in anakia, but these probaby
> > could be removed in a similar way).
> >
> > Best regards
> > Henning
> >
> >
> >
> > --- cut ---
> > Index:
> > src/java/org/apache/velocity/app/event/implement/EscapeReference.java
> > ===================================================================
> > --- src/java/org/apache/velocity/app/event/implement/EscapeReference.java
> > (revision 329578)
> > +++ src/java/org/apache/velocity/app/event/implement/EscapeReference.java
> > (working copy)
> > @@ -16,8 +16,10 @@
> > * limitations under the License.
> > */
> >
> > -import org.apache.oro.text.perl.MalformedPerl5PatternException;
> > -import org.apache.oro.text.perl.Perl5Util;
> > +import java.util.regex.Matcher;
> > +import java.util.regex.Pattern;
> > +import java.util.regex.PatternSyntaxException;
> > +
> > import org.apache.velocity.app.event.ReferenceInsertionEventHandler;
> > import org.apache.velocity.app.event.RuntimeServicesAware;
> > import org.apache.velocity.runtime.RuntimeServices;
> > @@ -43,9 +45,7 @@
> > * </PRE>
> > * <!-- note: ignore empty HTML comment above - breaks up star slash
> > avoiding javadoc end -->
> > *
> > - * Regular expressions should follow the "Perl5" format used by the ORO
> > regular expression
> > - * library. More info is at
> > - * <a
> > href="http://jakarta.apache.org/oro/api/org/apache/oro/text/perl/package-summary.html">http://jakarta.apache.org/oro/api/org/apache/oro/text/perl/package-summary.html</a>.
> > + * Regular expressions should follow the "regex5" format used by the
> > java.util.regex package
> > *
> > * @author <a href="mailto:[EMAIL PROTECTED]">Will Glass-Husain </a>
> > * @version $Id$
> > @@ -53,8 +53,6 @@
> > public abstract class EscapeReference implements
> > ReferenceInsertionEventHandler,RuntimeServicesAware {
> >
> >
> > - private Perl5Util perl = new Perl5Util();
> > -
> > private RuntimeServices rs;
> >
> > private String matchRegExp = null;
> > @@ -92,16 +90,25 @@
> > {
> > return escape(value);
> > }
> > -
> > - else if (perl.match(matchRegExp,reference))
> > +
> > + try
> > {
> > - return escape(value);
> > + Pattern p = Pattern.compile(matchRegExp);
> > + Matcher m = p.matcher(reference);
> > +
> > + if (m.find())
> > + {
> > + return escape(value);
> > + }
> > }
> > -
> > - else
> > + catch (PatternSyntaxException pse)
> > {
> > - return value;
> > + rs.getLog().error("Invalid regular expression '" +
> > matchRegExp
> > + + "'. No escaping will be performed.");
> > + matchRegExp = null;
> > }
> > +
> > + return value;
> > }
> >
> > /**
> > @@ -115,9 +122,19 @@
> > * Get the regular expression pattern.
> > */
> > matchRegExp =
> > rs.getConfiguration().getString(getMatchAttribute());
> > - if ((matchRegExp != null) && (matchRegExp.trim().length() == 0))
> > +
> > + if (matchRegExp != null)
> > {
> > - matchRegExp = null;
> > + matchRegExp = matchRegExp.trim();
> > + if (matchRegExp.startsWith("/") && matchRegExp.endsWith("/"))
> > + {
> > + matchRegExp = matchRegExp.substring(1,
> > matchRegExp.length() - 1);
> > + }
> > +
> > + if (matchRegExp.length() == 0)
> > + {
> > + matchRegExp = null;
> > + }
> > }
> >
> > /**
> > @@ -125,18 +142,17 @@
> > */
> > if (matchRegExp != null)
> > {
> > - try
> > + try
> > {
> > - perl.match(matchRegExp,"");
> > - }
> > - catch (MalformedPerl5PatternException E)
> > + Pattern.compile(matchRegExp);
> > + }
> > + catch (PatternSyntaxException pse)
> > {
> > rs.getLog().error("Invalid regular expression '" +
> > matchRegExp
> > - + "'. No escaping will be
> > performed.");
> > + + "'. No escaping will be performed.");
> > matchRegExp = null;
> > }
> > }
> > -
> > }
> >
> > /**
> >
> > --- cut ---
> > --
> > Dipl.-Inf. (Univ.) Henning P. Schmiedehausen INTERMETA GmbH
> > [EMAIL PROTECTED] +49 9131 50 654 0 http://www.intermeta.de/
> >
> > RedHat Certified Engineer -- Jakarta Turbine Development -- hero for hire
> > Linux, Java, perl, Solaris -- Consulting, Training, Development
> >
> > 4 - 8 - 15 - 16 - 23 - 42
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]