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: -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
|