jakarta-oro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 34309] New: - REMatcher freezes
Date Tue, 05 Apr 2005 16:22:07 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=34309>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=34309

           Summary: REMatcher freezes
           Product: ORO
           Version: 2.0.8
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
        AssignedTo: oro-dev@jakarta.apache.org
        ReportedBy: jan.moravec@ips-ag.cz


The following code demonstrates an issue we bumped into using ORO's REMatcher. 
The following regexp causes the REMatcher to freeze when matching the later two 
email addresses below.

import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;

public class FreezingMatches
{
  private static final String E_ADDRESS_NAME = "(\\w|-)+((\\w|-|.)+)*";
  private static final String E_ADDRESS_DOMAIN = "([a-zA-Z0-9]+(\\w|-)*\\.)+[a-
zA-Z0-9]{2,4}";
  private static final String E_ADDRESS_PATTERN = "^" + E_ADDRESS_NAME + "@" + 
E_ADDRESS_DOMAIN + "$";
  private static final String NAME_ADDRESS_PATTERN = "^[a-zA-Z0-9]+$";
  private static final String ADDRESS_PATTERN = "((" + E_ADDRESS_PATTERN + ")|
(" + NAME_ADDRESS_PATTERN + "))";

  /**
   * Pattern used to validate recepient email address(es).
   */
  private static Pattern EMAIL_ADDRESS_PATTERN;

  //public static final String ADDR = "hmor@seznam.cz"; - work OK
  //public static final String ADDR = "ondra@flashback-cz.net"; - freezes
  public static final String ADDR = "ondra@flashback.net"; - freezes

  static
  {
    Perl5Compiler RECompiler = new Perl5Compiler();
    try
    {
      EMAIL_ADDRESS_PATTERN = RECompiler.compile( ADDRESS_PATTERN );
    }
    catch (MalformedPatternException e)
    {
      e.printStackTrace();
    }
  }

  public static void main( String[] args )
  {
    Perl5Matcher REMatcher = new Perl5Matcher();

    if ( REMatcher.matches( ADDR, EMAIL_ADDRESS_PATTERN ) )
      System.out.println( "Matches" );
    else
      System.out.println( "Does not match" );
  }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: oro-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: oro-dev-help@jakarta.apache.org


Mime
View raw message