helpRegular Expressions for Java - Support: sr #105180, Some regexes lead to infinite loop

 
 

sr #105180: Some regexes lead to infinite loop

Submitted by:  None
Submitted on:  Wed 22 Feb 2006 10:07:57 PM UTC  
 
Category:  None Priority:  5 - Normal
Severity:  5 - Blocker Status:  None
Privacy:  Public Assigned to:  None
Originator Email:  -email is unavailable- Open/Closed:  Open
Operating System:  Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 22 Feb 2006 10:07:57 PM UTC, original submission:

I ran across a regex that, if run using substituteAll(), will result in an infinite loop for some reason. The regex is below, and has only been modified slightly to hide my company's info. The regex is used to strip off some personal information from incoming email replies we receive, and is very "fuzzy" to account for how email clients can really screw with the text. The regex is:

new RE("This.{0,10}?email.{0,10}?is.{0,10}?for.{0,10}?registered.{0,10}?members.{0,10}?of.{0,10}?OurSite.{0,10}?only[^\\.]*\\..{0,10}You.{0,10}?joined.{0,10}?OurSite.{0,10}?under.{0,10}?the.{0,10}?name.*?on.{0,10}?\\d+/\\d+/\\d+[^\\.]*\\..{0,10}You.{0,10}?can.{0,10}?turn.{0,10}?this.{0,10}?email.{0,10}?off.{0,10}?from.{0,10}?the.{0,10}?links.{0,10}?at.{0,10}?the.{0,10}?bottom.{0,10}?of.{0,10}?this.{0,10}?message[^\\.]*\\.?
, RE.REG_DOT_NEWLINE, RESyntax.RE_SYNTAX_PERL5_S);

It will usually work fine. But we received an email today that contained the following text, which when run against this regex, resulted in an infinite loop (notice the message text is cut off before the end of the regex would have matched):

Date: Tue, 21 Feb 2006 21:08:04 -0800 (PST)
From: -email is unavailable-
Subject: Yahoo! Auto Response
To: OurSite <ouraddress@oursite.net>
MIME-Version: 1.0
Content-Type: text/plain

This email is for registered members of OurSite only. You joined
OurSite under the name Joe Smith on 11/29/2000. You can turn
this email off from the links at the bottom of this mes

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follows 1 latest change.

Date Changed by Updated Field Previous Value => Replaced by
Wed 22 Feb 2006 10:07:57 PM UTC None Carbon-Copy- => Added nospam --AT-- thanks --DOT-- com

Back to the top


Powered by Savane 3.3