You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by John Hardin <jh...@impsec.org> on 2009/09/21 05:54:55 UTC
Unbalanced curly braces don't generate warning or error
Folks:
While doing a close eyeball lint of a misbehaving complex rule, I noticed
I had made a rather subtle typo:
mumble{x,y]mumble
Note the closing _square_ bracket. I guess I missed the [SHIFT] key... :)
This did not generate any lint or runtime errors.
Any idea why? I would expect the perl RE engine to have a problem with
unbalanced curly braces like that, but a quick test shows it does not (at
least, not in 5.8.8)! I would have thought you'd have to escape a curly
brace to match it literally, just like you do square brackets...
Does this deserve any special checking, like the || test? If so, I'll open
a bug. Or might it be a bug in perl's RE parser?
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
The yardstick you should use when considering whether to support a
given piece of legislation is "what if my worst enemy is chosen to
administer this law?"
-----------------------------------------------------------------------
18 days since a sunspot last seen - EPA blames CO2 emissions
Re: Unbalanced curly braces don't generate warning or error
Posted by Mark Martinec <Ma...@ijs.si>.
> > It is not an error. Perl is just too damn smart,
>
> I was wondering about that. Do you know if there is a way to turn that
> off and get a syntax error?
I'm afraid that is not possible. I'd be delighted if several
of these 'smart features' could have been disabled in perl,
but it's probably against its concept, or at least against
backwards compatibility.
Mark
Re: Unbalanced curly braces don't generate warning or error
Posted by John Hardin <jh...@impsec.org>.
On Mon, 21 Sep 2009, Mark Martinec wrote:
>> mumble{x,y]mumble
>>
>> Does this deserve any special checking, like the || test? If so, I'll
>> open a bug. Or might it be a bug in perl's RE parser?
>
> It is not an error. Perl is just too damn smart,
I was wondering about that. Do you know if there is a way to turn that
off and get a syntax error?
Thanks.
--
John Hardin KA7OHZ http://www.impsec.org/~jhardin/
jhardin@impsec.org FALaholic #11174 pgpk -a jhardin@impsec.org
key: 0xB8732E79 -- 2D8C 34F4 6411 F507 136C AF76 D822 E6E6 B873 2E79
-----------------------------------------------------------------------
A sword is never a killer, it is but a tool in the killer's hands.
-- Lucius Annaeus Seneca (Martial) 4BC-65AD
-----------------------------------------------------------------------
19 days since a sunspot last seen - EPA blames CO2 emissions
Re: Unbalanced curly braces don't generate warning or error
Posted by Mark Martinec <Ma...@ijs.si>.
> While doing a close eyeball lint of a misbehaving complex rule, I noticed
> I had made a rather subtle typo:
> mumble{x,y]mumble
> Note the closing _square_ bracket. I guess I missed the [SHIFT] key... :)
>
> This did not generate any lint or runtime errors.
>
> Any idea why? I would expect the perl RE engine to have a problem with
> unbalanced curly braces like that, but a quick test shows it does not (at
> least, not in 5.8.8)! I would have thought you'd have to escape a curly
> brace to match it literally, just like you do square brackets...
>
> Does this deserve any special checking, like the || test? If so, I'll open
> a bug. Or might it be a bug in perl's RE parser?
It is not an error. Perl is just too damn smart, and understands that
you 'meant' a literal '{' when it is not closed. There are other similar
cases, like unquoted $ or #, etc.
> Does this deserve any special checking, like the || test?
I don't think so, otherwise we could end up re-implementing the perl
expression parsing. I have my doubts on a need for '||' hand-holding,
but never mind.
Mark