[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange regexp behavior
From: |
David Bateman |
Subject: |
Re: strange regexp behavior |
Date: |
Tue, 23 Sep 2008 11:04:44 +0200 |
User-agent: |
Thunderbird 2.0.0.16 (X11/20080725) |
Thomas Weber wrote:
On Thu, Sep 18, 2008 at 11:34:55AM +0200, David Bateman wrote:
Thomas Weber wrote:
I'm currently discussing this with PCRE developers on their list,
http://lists.exim.org/lurker/message/20080915.202357.7f71f452.en.html
I already learned that this innocent looking pattern is a bad citizen :)
Ok, tell us what happens with this thread.
Patch attached; I've included a user-visible warning, because Phil Hazel
(pcre's author) suggested that a regexp triggering such a problem should
be rephrased.
Maybe calling OCTAVE_QUIT in the added while-loop would be sensible as
well.
Patch is against 3.0.2, I had trouble compiling current tip.
Looking at the patch it looks ok to me, however maybe
while (matches == PCRE_ERROR_MATCHLIMIT)
{
pe.match_limit *= 10;
matches = pcre_exec(re, &pe, buffer.c_str(),
buffer.length(), idx,
(idx ? PCRE_NOTBOL : 0),
ovector, (subpatterns+1)*3);
}
should be written as
#define PCRE_MATCHLIMIT_MAX 10
int i = 0;
while (matches == PCRE_ERROR_MATCHLIMIT && i++ < PCRE_MATCHLIMIT_MAX)
{
pe.match_limit *= 10;
matches = pcre_exec(re, &pe, buffer.c_str(),
buffer.length(), idx,
(idx ? PCRE_NOTBOL : 0),
ovector, (subpatterns+1)*3);
}
to avoid a truly infinite recursion in the pattern string. The max limit
might need adjusting.. What issues did you have copiling with the tip?
Regards
David
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
- Re: strange regexp behavior, (continued)
- Re: strange regexp behavior, Sergei Steshenko, 2008/09/12
- Re: strange regexp behavior, dbateman, 2008/09/13
- Re: strange regexp behavior, Thomas Weber, 2008/09/14
- Re: strange regexp behavior, G.., 2008/09/18
- Re: strange regexp behavior, David Bateman, 2008/09/18
- Re: strange regexp behavior, G.., 2008/09/18
- Re: strange regexp behavior, David Bateman, 2008/09/18
- Re: strange regexp behavior, Thomas Weber, 2008/09/18
- Re: strange regexp behavior, David Bateman, 2008/09/18
- Re: strange regexp behavior, Thomas Weber, 2008/09/21
- Re: strange regexp behavior,
David Bateman <=
- Message not available
- Re: strange regexp behavior, David Bateman, 2008/09/23
- Re: strange regexp behavior, John W. Eaton, 2008/09/24
- Re: strange regexp behavior, Jaroslav Hajek, 2008/09/29