Bug 7369

Summary: Unescaped left brace in regex is deprecated
Product: Spamassassin Reporter: chorny <alexchorny>
Component: LibrariesAssignee: SpamAssassin Developer Mailing List <dev>
Status: RESOLVED DUPLICATE    
Severity: normal CC: alexchorny, billcole, jhardin, jquinn+SAbug, lista, philip
Priority: P2    
Version: unspecified   
Target Milestone: Undefined   
Hardware: PC   
OS: All   
Whiteboard:

Description chorny 2016-11-11 22:28:32 UTC
This is new warning in 5.24 and in 5.26 it will be fatal error.

Unescaped left brace in regex is deprecated here, passed through in regex; marked by <-- HERE in m/^(.{ <-- HERE ,200}).*$/ at ../blib/lib/Mail/SpamAssassin/PerMsgStatus.pm line 921.

See for ex. http://www.cpantesters.org/cpan/report/2175cb2a-69fe-11e6-b500-799f71b19ea6
Comment 1 John Hardin 2016-11-11 22:32:58 UTC
...so now you have to explicitly say ".{0,nnn}" for "0-n instances of"?

How many REs does this change break worldwide?
Comment 2 John Hardin 2016-11-11 22:44:32 UTC
Looks like it. The perlre documentation does not mention the {,n} quantifier syntax, back as far as 5.12. I don't know when that change occurred, but it looks like we need to clean up the code and potentially the rules to do explicit {0,n} quantifiers, and post a warning on the users list for people to review their local rules.

How many versions back do we fix this?
Comment 3 chorny 2016-11-12 01:27:55 UTC
(In reply to John Hardin from comment #1)
> ...so now you have to explicitly say ".{0,nnn}" for "0-n instances of"?

Tested /a{,2}/ on perl 5.14.0. It does not work as /a{0,2}/. But it is same as /a\{,2\}/.
Comment 4 John Hardin 2016-11-12 03:13:34 UTC
...ugh. Is that sed I'm remembering then that supports the {,n} syntax?
Comment 5 Joe Quinn 2017-02-04 15:31:47 UTC
$ grep --recursive '{,' lib/
lib/Mail/SpamAssassin/PerMsgStatus.pm:  $str =~ s/^(.{,200}).*$/$1/gs;

Looks like this is the only regex that is affected.
Comment 6 James Lee 2017-07-04 10:41:57 UTC
(In reply to chorny from comment #3)

> Tested /a{,2}/ on perl 5.14.0. It does not work as /a{0,2}/. But it is same
> as /a\{,2\}/.

"does not work" is surely defined by the comment above the failed regex:

  # in case the last line was huge, trim it back to around 200 chars

and "{,2}" does not work to trim the line in earlier version of perl either.

To trim the line to 200 chars "s/^(.{0,200}).*$/$1/gs" should be correct.



Any reason why something so basic has been left for 8 month?  Is spamassassin unmaintained?

Unescaped left brace in regex is deprecated here (and will be fatal in Perl 5.30), passed through in regex; marked by <-- HERE in m/^(.{ <-- HERE ,200}).*$/ at /opt/xxxx/lib/perl5/xxxx/Mail/SpamAssassin/PerMsgStatus.pm line 921.

Note: and will be **fatal** in Perl 5.30
Comment 7 Bill Cole 2017-07-05 02:26:05 UTC
Fixed in r1791013 for Bug #7404

*** This bug has been marked as a duplicate of bug 7404 ***
Comment 8 Kevin A. McGrail 2018-04-19 17:57:53 UTC
*** Bug 7576 has been marked as a duplicate of this bug. ***